@brightspace-ui/core 3.152.0 → 3.153.1

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.
@@ -21,6 +21,11 @@ export const LinkMixin = superclass => class extends LocalizeCoreElement(supercl
21
21
  * @type {string}
22
22
  */
23
23
  href: { type: String },
24
+ /**
25
+ * Label for the link
26
+ * @type {string}
27
+ */
28
+ ariaLabel: { type: String, attribute: 'aria-label' },
24
29
  /**
25
30
  * Where to display the linked URL
26
31
  * @type {string}
@@ -52,14 +57,14 @@ export const LinkMixin = superclass => class extends LocalizeCoreElement(supercl
52
57
  `];
53
58
  }
54
59
 
55
- _render(inner, { rel = undefined, ariaLabel = undefined, linkClasses = {}, tabindex = undefined } = {}) {
60
+ _render(inner, { rel = undefined, linkClasses = {}, tabindex = undefined } = {}) {
56
61
  /*
57
62
  * NOTICE:
58
63
  * All html template whitespace within this component is critical to proper rendering and wrapping.
59
64
  * Do not modify for readability!
60
65
  */
61
66
  return html`<a
62
- aria-label="${ifDefined(ariaLabel)}"
67
+ aria-label="${ifDefined(this.ariaLabel)}"
63
68
  class="${classMap(linkClasses)}"
64
69
  download="${ifDefined(this.download)}"
65
70
  href="${ifDefined(this.href)}"
@@ -3,11 +3,14 @@ import '../scroll-wrapper/scroll-wrapper.js';
3
3
  import { css, html, LitElement, nothing } from 'lit';
4
4
  import { cssSizes } from '../inputs/input-checkbox.js';
5
5
  import { getComposedParent } from '../../helpers/dom.js';
6
+ import { getFlag } from '../../helpers/flags.js';
6
7
  import { PageableMixin } from '../paging/pageable-mixin.js';
7
8
  import ResizeObserver from 'resize-observer-polyfill/dist/ResizeObserver.es.js';
8
9
  import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
9
10
  import { SelectionMixin } from '../selection/selection-mixin.js';
10
11
 
12
+ const colSyncFix = getFlag('GAUD-8228-8186-improved-table-col-sync', true);
13
+
11
14
  export const tableStyles = css`
12
15
  .d2l-table {
13
16
  border-collapse: separate; /* needed to override reset stylesheets */
@@ -248,8 +251,22 @@ export const tableStyles = css`
248
251
  }
249
252
 
250
253
  /* sticky + scroll-wrapper */
251
- d2l-table-wrapper[sticky-headers][sticky-headers-scroll-wrapper] .d2l-table {
252
- display: block;
254
+ ${colSyncFix ? css`
255
+ d2l-table-wrapper[sticky-headers][sticky-headers-scroll-wrapper]:not([_no-scroll-width]) .d2l-table {
256
+ display: flex;
257
+ flex-direction: column;
258
+ }
259
+
260
+ d2l-table-wrapper[sticky-headers][sticky-headers-scroll-wrapper][_no-scroll-width] .d2l-table > thead {
261
+ display: table-header-group;
262
+ }
263
+
264
+ d2l-table-wrapper[sticky-headers][sticky-headers-scroll-wrapper][_no-scroll-width] .d2l-table > tbody {
265
+ display: table-row-group;
266
+ }` : css`
267
+ d2l-table-wrapper[sticky-headers][sticky-headers-scroll-wrapper] .d2l-table {
268
+ display: block;
269
+ }`
253
270
  }
254
271
 
255
272
  d2l-table-wrapper[sticky-headers][sticky-headers-scroll-wrapper] .d2l-table > thead {
@@ -318,7 +335,12 @@ export class TableWrapper extends RtlMixin(PageableMixin(SelectionMixin(LitEleme
318
335
  reflect: true,
319
336
  type: String
320
337
  },
321
- _controlsScrolled: { state: true }
338
+ _controlsScrolled: { state: true },
339
+ _noScrollWidth: {
340
+ attribute: '_no-scroll-width',
341
+ reflect: true,
342
+ type: Boolean,
343
+ },
322
344
  };
323
345
  }
324
346
 
@@ -383,6 +405,7 @@ export class TableWrapper extends RtlMixin(PageableMixin(SelectionMixin(LitEleme
383
405
  this._controlsMutationObserver = null;
384
406
  this._controlsScrolled = false;
385
407
  this._controlsScrolledMutationObserver = null;
408
+ this._noScrollWidth = colSyncFix;
386
409
  this._table = null;
387
410
  this._tableIntersectionObserver = null;
388
411
  this._tableMutationObserver = null;
@@ -582,13 +605,16 @@ export class TableWrapper extends RtlMixin(PageableMixin(SelectionMixin(LitEleme
582
605
  this._tableIntersectionObserver.observe(this._table);
583
606
  }
584
607
 
585
- if (!this._tableResizeObserver) this._tableResizeObserver = new ResizeObserver(() => this._syncColumnWidths());
608
+ if (!this._tableResizeObserver) this._tableResizeObserver = new ResizeObserver(entries => this._syncColumnWidths(entries));
586
609
  this._tableResizeObserver.observe(this._table);
610
+ colSyncFix && this.querySelectorAll('tr:first-child *').forEach(el => this._tableResizeObserver.observe(el));
587
611
 
588
612
  this._handleTableChange();
589
613
  }
590
614
 
591
615
  async _handleTableChange(mutationRecords) {
616
+ const updateList = [];
617
+
592
618
  const updates = { count: true, classNames: true, sticky: true, syncWidths: true };
593
619
  if (mutationRecords) {
594
620
  for (const key in updates) updates[key] = false;
@@ -601,6 +627,8 @@ export class TableWrapper extends RtlMixin(PageableMixin(SelectionMixin(LitEleme
601
627
  updates.sticky ||= target.matches(SELECTORS.headers);
602
628
  const affectedNodes = [...removedNodes, ...addedNodes];
603
629
  for (const node of affectedNodes) {
630
+ updateList.push(target, ...addedNodes);
631
+
604
632
  if (!(node instanceof Element)) continue;
605
633
  updates.classNames ||= node.matches('tr, td, th');
606
634
  updates.syncWidths ||= node.matches('tr');
@@ -614,6 +642,7 @@ export class TableWrapper extends RtlMixin(PageableMixin(SelectionMixin(LitEleme
614
642
 
615
643
  if (updates.count) this._updateItemShowingCount();
616
644
  if (updates.classNames) this._applyClassNames();
645
+ colSyncFix && await Promise.all([...updateList, ...this.querySelectorAll('d2l-table-col-sort-button')].map(n => n.updateComplete));
617
646
  if (updates.syncWidths) this._syncColumnWidths();
618
647
  if (updates.sticky) this._updateStickyTops();
619
648
  }
@@ -628,11 +657,14 @@ export class TableWrapper extends RtlMixin(PageableMixin(SelectionMixin(LitEleme
628
657
  }
629
658
 
630
659
  _syncColumnWidths() {
631
- if (!this._table || !this.stickyHeaders || !this.stickyHeadersScrollWrapper) return;
632
-
633
660
  const head = this._table.querySelector('thead');
634
661
  const body = this._table.querySelector('tbody');
635
- if (!head || !body) return;
662
+
663
+ if (colSyncFix) {
664
+ const maxScrollWidth = Math.max(head?.scrollWidth, body?.scrollWidth);
665
+ this._noScrollWidth = this.clientWidth === maxScrollWidth;
666
+ }
667
+ if (!head || !body || !this._table || !this.stickyHeaders || !this.stickyHeadersScrollWrapper || this._noScrollWidth) return;
636
668
 
637
669
  const candidateRowHeadCells = [];
638
670
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.152.0",
3
+ "version": "3.153.1",
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",