@brightspace-ui/core 2.29.3 → 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
  }
@@ -7,20 +7,31 @@ Tooltips display additional information when users focus or hover on a point of
7
7
  <script type="module">
8
8
  import '@brightspace-ui/core/components/button/button.js';
9
9
  import '@brightspace-ui/core/components/tooltip/tooltip.js';
10
+ import '@brightspace-ui/core/components/tooltip/tooltip-help.js';
10
11
 
11
12
  window.addEventListener('load', function () {
12
13
  setTimeout(function() {
13
- var tooltip = document.querySelector('#tooltip');
14
+ const tooltip = document.querySelector('#tooltip');
15
+ const helpTooltip = document.querySelector('#help-tooltip');
16
+
14
17
  tooltip.showing = true;
18
+ helpTooltip.showing = true;
15
19
  }, 20);
16
20
  });
17
21
  </script>
22
+
18
23
  <d2l-button id="tooltip-button">Hover here</d2l-button>
19
24
  <d2l-tooltip id="tooltip" for="tooltip-button">
20
25
  Tooltip message example
21
26
  </d2l-tooltip>
27
+
28
+ <d2l-tooltip-help id="help-tooltip" text="Hover here">
29
+ Tooltip message example
30
+ </d2l-tooltip-help>
22
31
  ```
23
32
 
33
+ Note: there is a [known defect](https://rally1.rallydev.com/#/?detail=/defect/641656338755&fdp=true) for tooltips, where they are sometimes rendered offset by some amount unexpectedly.
34
+
24
35
  ## Accessibility
25
36
 
26
37
  **Interactive Target Elements:**
@@ -69,7 +80,16 @@ The `d2l-tooltip` component is used to display additional information when users
69
80
  import '@brightspace-ui/core/components/inputs/input-text.js';
70
81
  import '@brightspace-ui/core/components/tooltip/tooltip.js';
71
82
  </script>
72
-
83
+ <!-- docs: start hidden content -->
84
+ <script>
85
+ window.addEventListener('load', function () {
86
+ setTimeout(function() {
87
+ const tooltip = document.querySelector('d2l-tooltip');
88
+ tooltip.showing = true;
89
+ }, 20);
90
+ });
91
+ </script>
92
+ <!-- docs: end hidden content -->
73
93
  <d2l-input-text placeholder="Hover for Error" id="tooltip-error" aria-invalid="true" label="Text Input" label-hidden style="max-width:250px;"></d2l-input-text>
74
94
  <d2l-tooltip for="tooltip-error" state="error">
75
95
  Your error message will display here
@@ -121,6 +141,16 @@ In the following example to constrain the tooltip to the dashed boundary we can
121
141
  import '@brightspace-ui/core/components/button/button.js';
122
142
  import '@brightspace-ui/core/components/tooltip/tooltip.js';
123
143
  </script>
144
+ <!-- docs: start hidden content -->
145
+ <script>
146
+ window.addEventListener('load', function () {
147
+ setTimeout(function() {
148
+ const tooltip = document.querySelector('d2l-tooltip');
149
+ tooltip.showing = true;
150
+ }, 20);
151
+ });
152
+ </script>
153
+ <!-- docs: end hidden content -->
124
154
  <style>
125
155
  .boundary {
126
156
  border: 1px dashed #cdd5dc;
@@ -163,15 +193,24 @@ The `d2l-tooltip-help` component is used to display additional information when
163
193
  <!-- docs: end donts -->
164
194
  <!-- docs: end best practices -->
165
195
 
166
- <!-- docs: demo live name:d2l-tooltip-help autoSize:false size:small -->
196
+ <!-- docs: demo live name:d2l-tooltip-help autoSize:false size:medium -->
167
197
  ```html
168
198
  <script type="module">
169
199
  import '@brightspace-ui/core/components/tooltip/tooltip-help.js';
170
200
  </script>
171
-
172
- <p class="d2l-body-standard">
201
+ <!-- docs: start hidden content -->
202
+ <script>
203
+ window.addEventListener('load', function () {
204
+ setTimeout(function() {
205
+ const tooltip = document.querySelector('d2l-tooltip-help');
206
+ tooltip.showing = true;
207
+ }, 20);
208
+ });
209
+ </script>
210
+ <!-- docs: end hidden content -->
211
+ <p class="d2l-body-compact">
173
212
  This is some sample text.
174
- <d2l-tooltip-help text="Helpful label" inherit-font-style>Contents should elaborate on the label (be short and concise)</d2l-tooltip-help>
213
+ <d2l-tooltip-help text="Helpful label">Contents should elaborate on the label (be short and concise)</d2l-tooltip-help>
175
214
  </p>
176
215
  ```
177
216
 
@@ -25,6 +25,10 @@ class TooltipHelp extends FocusMixin(FocusVisiblePolyfillMixin(LitElement)) {
25
25
  * @type {'top'|'bottom'|'left'|'right'}
26
26
  */
27
27
  position: { type: String },
28
+ /**
29
+ * @ignore
30
+ */
31
+ showing: { type: Boolean, reflect: true },
28
32
  /**
29
33
  * REQUIRED: Text that will render as the Help Tooltip opener
30
34
  * @type {string}
@@ -44,8 +48,8 @@ class TooltipHelp extends FocusMixin(FocusVisiblePolyfillMixin(LitElement)) {
44
48
  #d2l-tooltip-help-text {
45
49
  background: none;
46
50
  border: none;
51
+ cursor: text;
47
52
  padding: 0;
48
- text-decoration-color: var(--d2l-color-galena);
49
53
  text-decoration-line: underline;
50
54
  text-decoration-style: dashed;
51
55
  text-decoration-thickness: 1px;
@@ -75,6 +79,7 @@ class TooltipHelp extends FocusMixin(FocusVisiblePolyfillMixin(LitElement)) {
75
79
  super();
76
80
 
77
81
  this.inheritFontStyle = false;
82
+ this.showing = false;
78
83
  }
79
84
 
80
85
  static get focusElementSelector() {
@@ -97,7 +102,7 @@ class TooltipHelp extends FocusMixin(FocusVisiblePolyfillMixin(LitElement)) {
97
102
  <button id="d2l-tooltip-help-text" class="${classMap(classes)}">
98
103
  ${this.text}
99
104
  </button>
100
- <d2l-tooltip for="d2l-tooltip-help-text" delay="0" offset="13" position="${ifDefined(this.position)}">
105
+ <d2l-tooltip for="d2l-tooltip-help-text" delay="0" offset="13" position="${ifDefined(this.position)}" ?showing="${this.showing}">
101
106
  <slot></slot>
102
107
  </d2l-tooltip>
103
108
  `;
@@ -10049,6 +10049,11 @@
10049
10049
  "description": "Allows this component to inherit certain font properties",
10050
10050
  "type": "boolean",
10051
10051
  "default": "false"
10052
+ },
10053
+ {
10054
+ "name": "showing",
10055
+ "type": "boolean",
10056
+ "default": "false"
10052
10057
  }
10053
10058
  ],
10054
10059
  "slots": [