@brightspace-ui/core 2.29.5 → 2.29.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -177,13 +177,35 @@ export const DialogMixin = superclass => class extends RtlMixin(superclass) {
177
177
  }
178
178
  }
179
179
 
180
+ _findAutofocusElement(node) {
181
+ if (this._useNative) {
182
+ // Do not override native autofocus attribute implementation
183
+ return null;
184
+ }
185
+
186
+ const slot = node.querySelector('slot');
187
+ if (!slot) {
188
+ // We are in a confirm dialog, autofocus attribute will never be set
189
+ return null;
190
+ }
191
+
192
+ const content = slot.assignedElements({ flatten: true });
193
+
194
+ let autofocusElement = null;
195
+ for (const el of content) {
196
+ autofocusElement = el.hasAttribute('autofocus') ? el : el.querySelector('[autofocus]');
197
+ if (autofocusElement) break;
198
+ }
199
+ return autofocusElement;
200
+ }
201
+
180
202
  _focusFirst() {
181
203
  if (!this.shadowRoot) return;
182
204
  const content = this.shadowRoot.querySelector('.d2l-dialog-content');
183
205
  if (content) {
184
- const firstFocusable = getNextFocusable(content);
185
- if (isComposedAncestor(this.shadowRoot.querySelector('.d2l-dialog-inner'), firstFocusable)) {
186
- forceFocusVisible(firstFocusable);
206
+ const elementToFocus = this._findAutofocusElement(content) ?? getNextFocusable(content);
207
+ if (isComposedAncestor(this.shadowRoot.querySelector('.d2l-dialog-inner'), elementToFocus)) {
208
+ forceFocusVisible(elementToFocus, false);
187
209
  return;
188
210
  }
189
211
  }
@@ -50,7 +50,6 @@ class TooltipHelp extends FocusMixin(FocusVisiblePolyfillMixin(LitElement)) {
50
50
  border: none;
51
51
  cursor: text;
52
52
  padding: 0;
53
- text-decoration-color: var(--d2l-color-galena);
54
53
  text-decoration-line: underline;
55
54
  text-decoration-style: dashed;
56
55
  text-decoration-thickness: 1px;
package/helpers/focus.js CHANGED
@@ -13,8 +13,8 @@ const focusableElements = {
13
13
  textarea: true
14
14
  };
15
15
 
16
- export function forceFocusVisible(elem) {
17
- if (!isFocusable(elem)) {
16
+ export function forceFocusVisible(elem, includeTabbablesOnly) {
17
+ if (!isFocusable(elem, false, includeTabbablesOnly)) {
18
18
  elem = getFirstFocusableDescendant(elem);
19
19
  }
20
20
  if (!elem) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.29.5",
3
+ "version": "2.29.6",
4
4
  "description": "A collection of accessible, free, open-source web components for building Brightspace applications",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/BrightspaceUI/core.git",