diff --git a/docs/pages/resources/changelog.md b/docs/pages/resources/changelog.md index bde02402..833af4a3 100644 --- a/docs/pages/resources/changelog.md +++ b/docs/pages/resources/changelog.md @@ -12,6 +12,10 @@ Components with the Experimental bad New versions of Shoelace are released as-needed and generally occur when a critical mass of changes have accumulated. At any time, you can see what's coming in the next release by visiting [next.shoelace.style](https://next.shoelace.style). +## Next + +- Fixed a bug in the submenu controller that prevented submenus from rendering in RTL without explicitly setting `dir` on the parent menu item [#1992] + ## 2.15.1 - Fixed a bug in `` where if a click did not contain a `` it would show a console error. [#2009] diff --git a/src/components/carousel/carousel.component.ts b/src/components/carousel/carousel.component.ts index 2a2912bc..78547576 100644 --- a/src/components/carousel/carousel.component.ts +++ b/src/components/carousel/carousel.component.ts @@ -153,7 +153,7 @@ export default class SlCarousel extends ShoelaceElement { private handleKeyDown(event: KeyboardEvent) { if (['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Home', 'End'].includes(event.key)) { const target = event.target as HTMLElement; - const isRtl = this.localize.dir() === 'rtl'; + const isRtl = this.matches(':dir(rtl)'); const isFocusInPagination = target.closest('[part~="pagination-item"]') !== null; const isNext = event.key === 'ArrowDown' || (!isRtl && event.key === 'ArrowRight') || (isRtl && event.key === 'ArrowLeft'); diff --git a/src/components/details/details.component.ts b/src/components/details/details.component.ts index 4e9df5c9..2a38fd41 100644 --- a/src/components/details/details.component.ts +++ b/src/components/details/details.component.ts @@ -187,7 +187,7 @@ export default class SlDetails extends ShoelaceElement { } render() { - const isRtl = this.localize.dir() === 'rtl'; + const isRtl = this.matches(':dir(rtl)'); return html`
{ const submenuSlot: HTMLSlotElement | null = this.host.renderRoot.querySelector("slot[name='submenu']"); const menu = submenuSlot?.assignedElements({ flatten: true }).filter(el => el.localName === 'sl-menu')[0]; - const isRtl = this.localize.dir() === 'rtl'; - + const isRtl = this.host.matches(':dir(rtl)'); if (!menu) { return; } @@ -267,7 +259,7 @@ export class SubmenuController implements ReactiveController { } renderSubmenu() { - const isLtr = this.localize.dir() === 'ltr'; + const isRtl = this.host.matches(':dir(rtl)'); // Always render the slot, but conditionally render the outer if (!this.isConnected) { @@ -277,7 +269,7 @@ export class SubmenuController implements ReactiveController { return html` t.matches(':focus')); - const isRtl = this.localize.dir() === 'rtl'; + const isRtl = this.matches(':dir(rtl)'); if (activeEl?.tagName.toLowerCase() === 'sl-tab') { let index = this.tabs.indexOf(activeEl); @@ -292,7 +292,7 @@ export default class SlTabGroup extends ShoelaceElement { const width = currentTab.clientWidth; const height = currentTab.clientHeight; - const isRtl = this.localize.dir() === 'rtl'; + const isRtl = this.matches(':dir(rtl)'); // We can't used offsetLeft/offsetTop here due to a shadow parent issue where neither can getBoundingClientRect // because it provides invalid values for animating elements: https://bugs.chromium.org/p/chromium/issues/detail?id=920069 @@ -370,7 +370,7 @@ export default class SlTabGroup extends ShoelaceElement { } render() { - const isRtl = this.localize.dir() === 'rtl'; + const isRtl = this.matches(':dir(rtl)'); return html`
0) { event.preventDefault();