@brightspace-ui/core 2.13.1 → 2.13.2

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.
@@ -41,6 +41,7 @@ class TagList extends LocalizeCoreElement(ArrowKeysMixin(LitElement)) {
41
41
  */
42
42
  description: { type: String },
43
43
  _chompIndex: { type: Number },
44
+ _contentReady: { type: Boolean },
44
45
  _lines: { type: Number },
45
46
  _showHiddenTags: { type: Boolean }
46
47
  };
@@ -68,11 +69,16 @@ class TagList extends LocalizeCoreElement(ArrowKeysMixin(LitElement)) {
68
69
  visibility: hidden;
69
70
  }
70
71
  .d2l-tag-list-clear-button {
72
+ position: absolute;
71
73
  visibility: hidden;
72
74
  }
73
75
  .d2l-tag-list-clear-button.d2l-tag-list-clear-button-visible {
76
+ position: static;
74
77
  visibility: visible;
75
78
  }
79
+ .tag-list-hidden {
80
+ visibility: hidden;
81
+ }
76
82
  `;
77
83
  }
78
84
 
@@ -82,8 +88,11 @@ class TagList extends LocalizeCoreElement(ArrowKeysMixin(LitElement)) {
82
88
  this.arrowKeysDirection = 'leftrightupdown';
83
89
  this.clearable = false;
84
90
  this._chompIndex = 10000;
91
+ this._clearButtonHeight = 0;
85
92
  this._clearButtonWidth = 0;
93
+ this._contentReady = false;
86
94
  this._hasResized = false;
95
+ this._itemHeight = 0;
87
96
  this._resizeObserver = null;
88
97
  this._showHiddenTags = false;
89
98
  }
@@ -111,6 +120,7 @@ class TagList extends LocalizeCoreElement(ArrowKeysMixin(LitElement)) {
111
120
  const clearButton = this.shadowRoot.querySelector('d2l-button-subtle.d2l-tag-list-clear-button');
112
121
  this._clearButtonResizeObserver = new ResizeObserver(() => {
113
122
  this._clearButtonWidth = Math.ceil(parseFloat(getComputedStyle(clearButton).getPropertyValue('width')));
123
+ this._clearButtonHeight = Math.ceil(parseFloat(getComputedStyle(clearButton).getPropertyValue('height')));
114
124
  });
115
125
  this._clearButtonResizeObserver.observe(clearButton);
116
126
  }
@@ -154,8 +164,13 @@ class TagList extends LocalizeCoreElement(ArrowKeysMixin(LitElement)) {
154
164
  'd2l-tag-list-clear-button-visible': this.clearable && this._items && this._items.length > 0
155
165
  };
156
166
 
167
+ const containerClasses = {
168
+ 'tag-list-container': true,
169
+ 'tag-list-hidden': !this._contentReady
170
+ };
171
+
157
172
  const list = html`
158
- <div role="list" class="tag-list-container" aria-label="${this.description}" @d2l-tag-list-item-clear="${this._handleItemDeleted}">
173
+ <div role="list" class="${classMap(containerClasses)}" aria-label="${this.description}" @d2l-tag-list-item-clear="${this._handleItemDeleted}">
159
174
  <slot @slotchange="${this._handleSlotChange}"></slot>
160
175
  ${overflowButton}
161
176
  <d2l-button-subtle
@@ -169,7 +184,8 @@ class TagList extends LocalizeCoreElement(ArrowKeysMixin(LitElement)) {
169
184
  `;
170
185
 
171
186
  const outerContainerStyles = {
172
- maxHeight: (this._showHiddenTags || !this._lines) ? undefined : `${(this._itemHeight + MARGIN_TOP_RIGHT) * this._lines}px`
187
+ maxHeight: (this._showHiddenTags || !this._lines) ? undefined : `${(this._itemHeight + MARGIN_TOP_RIGHT) * this._lines}px`,
188
+ minHeight: `${Math.max(this._clearButtonHeight, this._itemHeight)}px`
173
189
  };
174
190
 
175
191
  return html`
@@ -314,37 +330,37 @@ class TagList extends LocalizeCoreElement(ArrowKeysMixin(LitElement)) {
314
330
  }
315
331
  }
316
332
 
317
- _handleResize(entries) {
333
+ async _handleResize(entries) {
318
334
  this._availableWidth = Math.floor(entries[0].contentRect.width);
319
335
  if (this._availableWidth >= PAGE_SIZE.large) this._lines = PAGE_SIZE_LINES.large;
320
336
  else if (this._availableWidth < PAGE_SIZE.large && this._availableWidth >= PAGE_SIZE.medium) this._lines = PAGE_SIZE_LINES.medium;
321
337
  else this._lines = PAGE_SIZE_LINES.small;
322
338
  if (!this._hasResized) {
323
339
  this._hasResized = true;
324
- this._handleSlotChange();
340
+ await this._handleSlotChange();
325
341
  } else {
326
342
  this._chomp();
327
343
  }
328
344
  }
329
345
 
330
- _handleSlotChange() {
346
+ async _handleSlotChange() {
331
347
  if (!this._hasResized) return;
348
+ this._contentReady = false;
349
+ await this.updateComplete;
332
350
 
333
- setTimeout(async() => {
334
- this._items = await this._getTagListItems();
335
- if (!this._items || this._items.length === 0) {
336
- this._chompIndex = 10000;
337
- return;
338
- }
351
+ this._items = await this._getTagListItems();
352
+ if (!this._items || this._items.length === 0) {
353
+ this._chompIndex = 10000;
354
+ return;
355
+ }
339
356
 
340
- this._itemLayouts = this._getItemLayouts(this._items);
341
- this._itemHeight = this._items[0].offsetHeight;
342
- this._items.forEach((item, index) => {
343
- item.setAttribute('tabIndex', index === 0 ? 0 : -1);
344
- });
345
- this._chomp();
346
- this.requestUpdate();
347
- }, 40);
357
+ this._itemLayouts = this._getItemLayouts(this._items);
358
+ this._itemHeight = this._items[0].offsetHeight;
359
+ this._items.forEach((item, index) => {
360
+ item.setAttribute('tabIndex', index === 0 ? 0 : -1);
361
+ });
362
+ this._chomp();
363
+ this._contentReady = true;
348
364
  }
349
365
 
350
366
  async _toggleHiddenTagVisibility(e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.13.1",
3
+ "version": "2.13.2",
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",