Skip to content

Commit

Permalink
feat: table-col-sort-button: opt-in to prefer-fixed-positioning for d…
Browse files Browse the repository at this point in the history
…ropdown
  • Loading branch information
margaree committed Jan 22, 2025
1 parent d0a677c commit d680f2c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
3 changes: 3 additions & 0 deletions components/table/demo/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import '../../demo/demo-page.js';
import './table-test.js';
</script>
<script>
window.D2L = { LP: { Web: { UI: { Flags: { Flag: () => true } } } } };
</script>
</head>
<body unresolved>

Expand Down
4 changes: 2 additions & 2 deletions components/table/table-col-sort-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ export class TableColSortButton extends LocalizeCoreElement(FocusMixin(LitElemen
<slot></slot>${iconView}
</button><span id="${this._describedById}" hidden>${buttonDescription}</span>${sortedView}`;
if (this._hasDropdownItems) {
return html`<d2l-dropdown>
return html`<d2l-dropdown prefer-fixed-positioning>
${button}
<d2l-dropdown-menu no-pointer align="start" vertical-offset="0">
<d2l-dropdown-menu no-pointer align="start" vertical-offset="0" prefer-fixed-positioning>
<d2l-menu @d2l-table-col-sort-button-item-change="${this._handleTablColSortButtonItemChange}">
<slot name="items" @slotchange="${this._handleSlotChange}"></slot>
</d2l-menu>
Expand Down
20 changes: 20 additions & 0 deletions components/table/test/table.vdiff.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,26 @@ describe('table', () => {
await expect(elem).to.be.golden();
});

it('col-sort-button-dropdown-open-short-flag-off', async() => {
window.D2L = {};
const elem = await createTableFixture(html`
<thead>${createSortableButtonDropdownHeaderRow()}</thead>
<tbody>${createRows([1])}</tbody>
`);
await clickElem(elem.shadowRoot.querySelector('d2l-table-col-sort-button'));
await expect(elem).to.be.golden();
});

it('col-sort-button-dropdown-open-short-flag-on', async() => {
window.D2L = { LP: { Web: { UI: { Flags: { Flag: () => true } } } } };
const elem = await createTableFixture(html`
<thead>${createSortableButtonDropdownHeaderRow()}</thead>
<tbody>${createRows([1])}</tbody>
`);
await clickElem(elem.shadowRoot.querySelector('d2l-table-col-sort-button'));
await expect(elem).to.be.golden({ margin: 50 });
});

it('wrapper component', async() => {
const elem = await fixture(html`<d2l-test-table type="${type}"></d2l-test-table>`, { rtl });
await expect(elem).to.be.golden();
Expand Down

0 comments on commit d680f2c

Please sign in to comment.