Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/components/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ export class Menu implements ComponentInterface, MenuI {
* Menu direction animation is calculated based on the document direction.
* If the document direction changes, we need to create a new animation.
*/
const isEndSide = isEnd(this.side);
const isEndSide = isEnd(this.side, this.el);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think sideChanged() needs the same treatment. menu.tsx:153 still calls isEnd(this.side) with no host element, so it resolves from document.dir, while this line now resolves from the element's dir. In the ancestor-dir="rtl" case those two disagree, and this.isEndSide feeds the gesture math (checkEdgeSide, computeDelta) and the animation builders. Can you pass this.el at line 153 too so both call sites agree?

if (width === this.width && this.animation !== undefined && isEndSide === this.isEndSide) {
return;
}
Expand Down
9 changes: 7 additions & 2 deletions core/src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,15 @@ export const pointerCoord = (ev: any): { x: number; y: number } => {
* Given a side, return if it should be on the end
* based on the value of dir
* @param side the side
* @param hostElement the host element
* @param isRTL whether the application dir is rtl

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @param isRTL line is stale, there's no isRTL parameter. Since you're adding @param hostElement here anyway, mind dropping the isRTL line too?

*/
export const isEndSide = (side: Side): boolean => {
const isRTL = document.dir === 'rtl';
export const isEndSide = (side: Side, hostElement?: Element): boolean => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we get a test for the ancestor-dir="rtl" case? contributing.md asks for a test on behavior changes, and this one is easy to regress. A spec that sets dir="rtl" on a wrapper and asserts the animation side would lock it in.

const isRTL = hostElement
? hostElement.closest('[dir]')?.getAttribute('dir') === 'rtl'
: document.dir === 'rtl'
;
Comment on lines +326 to +329

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const isRTL = hostElement
? hostElement.closest('[dir]')?.getAttribute('dir') === 'rtl'
: document.dir === 'rtl'
;
const isRTL = hostElement
? hostElement.closest('[dir]')?.getAttribute('dir') === 'rtl'
: document.dir === 'rtl';

This is indented with tabs and has the ; hanging on its own line, so it fails npm run lint. npm run lint.fix would also sort it.


switch (side) {
case 'start':
return isRTL;
Expand Down
Loading