Skip to content

fix(popover): respect rtl for start and end alignment - #31775

Open
OS-jacobbell wants to merge 5 commits into
mainfrom
FW-7825
Open

OS-jacobbell wants to merge 5 commits into
mainfrom
FW-7825

Conversation

@OS-jacobbell

Copy link
Copy Markdown
Contributor

Issue number: resolves internal


What is the current behavior?

When popover side is top or bottom, start and end alignment does not respect RTL.

What is the new behavior?

  • When popover side is top or bottom, start alignment appears on the right in RTL mode, and end alignment appears on the left.

Does this introduce a breaking change?

  • Yes
  • No

Other information

@OS-jacobbell
OS-jacobbell requested a review from a team as a code owner November 18, 2026 18:21
@OS-jacobbell
OS-jacobbell requested a review from ShaneK November 18, 2026 18:21
@vercel

vercel Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ionic-framework Ready Ready Preview Nov 18, 2026 7:26pm UTC

Request Review

@github-actions github-actions Bot added the package: core @ionic/core package label Nov 18, 2026

@brandyscarney brandyscarney left a comment

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 fix looks good! Just a few small requests!

Comment on lines +867 to +891
switch (align) {
case 'start':
return { top: 0, left: 0 };
case 'end':
return { top: -(contentHeight - triggerBoundingBox.height), left: 0 };
case 'center':
return { top: -(contentHeight / 2 - triggerBoundingBox.height / 2), left: 0 };
}
}
case 'top':
case 'bottom':
default:
return {
top: 0,
left: -(contentWidth / 2 - triggerBoundingBox.width / 2),
};
default: {
/**
* If side is on the y-axis then the
* align values refer to the left and right
* margins of the content.
*/
switch (align) {
case 'start':
return { top: 0, left: isRTL ? -(contentWidth - triggerBoundingBox.width) : 0 };
case 'end':
return { top: 0, left: isRTL ? 0 : -(contentWidth - triggerBoundingBox.width) };
case 'center':
return { top: 0, left: -(contentWidth / 2 - triggerBoundingBox.width / 2) };
}

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.

Neither inner switch (align) has a default case. If align is anything but start/center/end, the x-axis block falls through to the y-axis block, which also returns nothing, so the function returns undefined. Then alignedCoordinates.top throws in getPopoverPosition and the popover never opens.

The old code had case 'start': default: returning { top: 0, left: 0 }. That covered a bad alignment attribute from plain HTML, and alignment set back to undefined after load (the prop is mutable, and the mode-based default is only applied in componentWillLoad).

Can we add a default to both inner switches so they fall back to start like before? An explicit return at the end of the x-axis block would also stop it falling into the y-axis case by accident.

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.

Can you update popover.tsx line 219-222:

The side JSDoc right above says which values are RTL-aware, but alignment doesn't. Now that start/end flip in RTL when side is top or bottom, should we say that here too?

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.

This changes where every md popover appears in RTL.

It's a bug fix, so it's not breaking, but could you mention in "What is the new behavior?" that default-alignment md popovers in RTL now open from the right? That way RTL users aren't surprised.

const popoverBox = (await page.locator(`.${id}-popover`).locator('.popover-content').boundingBox())!;

return {
trigger: { left: buttonBox.x, right: buttonBox.x + buttonBox.width, center: buttonBox.x + buttonBox.width / 2 },

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.

center is computed for both trigger and popover but no test reads it. Can we drop it, or add a center alignment test that uses it?

This branch was successfully deployed

1 active deployment
Preview — a11959bc Deployed Nov 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants