@brightspace-ui/core 2.23.0 → 2.23.3

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.
@@ -17,7 +17,9 @@ window.D2L.DialogMixin = window.D2L.DialogMixin || {};
17
17
 
18
18
  // while implemented in Webkit, native <dialog> focus mangement across slotted content is buggy
19
19
  // https://bugs.webkit.org/show_bug.cgi?id=233320
20
- window.D2L.DialogMixin.hasNative = (window.HTMLDialogElement !== undefined)
20
+ // starting in Chrome 102, all elements inside <dialog>s that are inside shadow roots have null offsetParent
21
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=1331803
22
+ window.D2L.DialogMixin.hasNative = false && (window.HTMLDialogElement !== undefined)
21
23
  && (navigator.vendor && navigator.vendor.toLowerCase().indexOf('apple') === -1);
22
24
  if (window.D2L.DialogMixin.preferNative === undefined) {
23
25
  window.D2L.DialogMixin.preferNative = true;
@@ -16,7 +16,8 @@ class FocusTrap extends FocusMixin(LitElement) {
16
16
  * Whether the component should trap user focus.
17
17
  * @type {boolean}
18
18
  */
19
- trap: { type: Boolean }
19
+ trap: { type: Boolean },
20
+ _legacyPromptIds: { state: true }
20
21
  };
21
22
  }
22
23
 
@@ -35,6 +36,9 @@ class FocusTrap extends FocusMixin(LitElement) {
35
36
  super();
36
37
  this.trap = false;
37
38
  this._handleBodyFocus = this._handleBodyFocus.bind(this);
39
+ this._handleLegacyPromptOpen = this._handleLegacyPromptOpen.bind(this);
40
+ this._handleLegacyPromptClose = this._handleLegacyPromptClose.bind(this);
41
+ this._legacyPromptIds = new Set();
38
42
  }
39
43
 
40
44
  static get focusElementSelector() {
@@ -44,15 +48,19 @@ class FocusTrap extends FocusMixin(LitElement) {
44
48
  connectedCallback() {
45
49
  super.connectedCallback();
46
50
  document.body.addEventListener('focus', this._handleBodyFocus, true);
51
+ document.body.addEventListener('d2l-legacy-prompt-open', this._handleLegacyPromptOpen);
52
+ document.body.addEventListener('d2l-legacy-prompt-close', this._handleLegacyPromptClose);
47
53
  }
48
54
 
49
55
  disconnectedCallback() {
50
56
  super.disconnectedCallback();
51
57
  document.body.removeEventListener('focus', this._handleBodyFocus, true);
58
+ document.body.removeEventListener('d2l-legacy-prompt-open', this._handleLegacyPromptOpen);
59
+ document.body.removeEventListener('d2l-legacy-prompt-close', this._handleLegacyPromptClose);
52
60
  }
53
61
 
54
62
  render() {
55
- const tabindex = this.trap ? '0' : undefined;
63
+ const tabindex = (this.trap && this._legacyPromptIds.size === 0) ? '0' : undefined;
56
64
  return html`
57
65
  <span class="d2l-focus-trap-start" @focusin="${this._handleStartFocusIn}" tabindex="${ifDefined(tabindex)}"></span>
58
66
  <slot></slot>
@@ -72,7 +80,7 @@ class FocusTrap extends FocusMixin(LitElement) {
72
80
  }
73
81
 
74
82
  _handleBodyFocus(e) {
75
- if (!this.trap) return;
83
+ if (!this.trap || this._legacyPromptIds.size > 0) return;
76
84
  const container = this._getContainer();
77
85
  const target = e.composedPath()[0];
78
86
  if (isComposedAncestor(container, target)) return;
@@ -95,6 +103,16 @@ class FocusTrap extends FocusMixin(LitElement) {
95
103
  this._focusFirst();
96
104
  }
97
105
 
106
+ _handleLegacyPromptClose(e) {
107
+ this._legacyPromptIds.delete(e.detail.id);
108
+ this.requestUpdate();
109
+ }
110
+
111
+ _handleLegacyPromptOpen(e) {
112
+ this._legacyPromptIds.add(e.detail.id);
113
+ this.requestUpdate();
114
+ }
115
+
98
116
  _handleStartFocusIn(e) {
99
117
  const container = this._getContainer();
100
118
  if (this.shadowRoot && isComposedAncestor(container, e.relatedTarget)) {
@@ -82,7 +82,6 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
82
82
  * @type {string}
83
83
  */
84
84
  value: { type: String },
85
- _hiddenCalendarHeight: { type: Number },
86
85
  _hiddenContentWidth: { type: String },
87
86
  _dateTimeDescriptor: { type: Object },
88
87
  _dropdownFirstOpened: { type: Boolean },
@@ -114,8 +113,7 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
114
113
  :host([disabled]) d2l-icon {
115
114
  opacity: 0.5;
116
115
  }
117
- .d2l-input-date-hidden-text,
118
- .d2l-input-date-hidden-calendar {
116
+ .d2l-input-date-hidden-text {
119
117
  font-family: inherit;
120
118
  font-size: 0.8rem;
121
119
  font-weight: 400;
@@ -154,7 +152,6 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
154
152
 
155
153
  this._dropdownFirstOpened = false;
156
154
  this._formattedValue = '';
157
- this._hiddenCalendarHeight = 415; // height of 6 date row calendar when 1rem = 20px
158
155
  this._hiddenContentWidth = '8rem';
159
156
  this._inputId = getUniqueId();
160
157
  this._inputTextFocusMouseup = false;
@@ -191,7 +188,6 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
191
188
  disconnectedCallback() {
192
189
  super.disconnectedCallback();
193
190
  if (this._hiddenContentResizeObserver) this._hiddenContentResizeObserver.disconnect();
194
- if (this._hiddenCalendarResizeObserver) this._hiddenCalendarResizeObserver.disconnect();
195
191
  }
196
192
 
197
193
  async firstUpdated(changedProperties) {
@@ -219,17 +215,6 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
219
215
  this._hiddenContentWidth = `${width}px`;
220
216
  });
221
217
  this._hiddenContentResizeObserver.observe(hiddenContent);
222
-
223
- const hiddenCalendar = this.shadowRoot.querySelector('.d2l-input-date-hidden-calendar');
224
- if (!hiddenCalendar) return;
225
- this._hiddenCalendarResizeObserver = new ResizeObserver(() => {
226
- const hiddenCalendarHeight = Math.ceil(parseFloat(getComputedStyle(hiddenCalendar).getPropertyValue('height')));
227
- if (hiddenCalendarHeight > 0) {
228
- this._hiddenCalendarHeight = hiddenCalendarHeight;
229
- this._hiddenCalendarResizeObserver.disconnect();
230
- }
231
- });
232
- this._hiddenCalendarResizeObserver.observe(hiddenCalendar);
233
218
  }
234
219
 
235
220
  render() {
@@ -252,7 +237,7 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
252
237
  @d2l-dropdown-open="${this._handleDropdownOpen}"
253
238
  @d2l-dropdown-focus-enter="${this._handleFocusTrapEnter}"
254
239
  max-width="335"
255
- min-height="${this._hiddenCalendarHeight}"
240
+ min-height="415"
256
241
  ?no-auto-fit="${!mediaQueryList.matches}"
257
242
  trap-focus
258
243
  no-auto-focus
@@ -307,13 +292,6 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
307
292
  </d2l-input-text>
308
293
  ${dropdownContent}
309
294
  </d2l-dropdown>
310
- ${!this._dropdownFirstOpened ? html`<div aria-hidden="true" class="d2l-input-date-hidden-calendar">
311
- <d2l-calendar selected-value="2018-09-08">
312
- <div class="d2l-calendar-slot-buttons">
313
- <d2l-button-subtle text="${this.localize(`${this._namespace}.today`)}"></d2l-button-subtle>
314
- </div>
315
- </d2l-calendar>
316
- </div>` : null}
317
295
  `;
318
296
  }
319
297
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.23.0",
3
+ "version": "2.23.3",
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",