Skip to content

fix: popup glitch when not enough width #510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 2 additions & 5 deletions src/hooks/useAlign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,7 @@ export default function useAlign(
const doc = popupElement.ownerDocument;
const win = getWin(popupElement);

const {
width,
height,
position: popupPosition,
} = win.getComputedStyle(popupElement);
const { position: popupPosition } = win.getComputedStyle(popupElement);

const originLeft = popupElement.style.left;
const originTop = popupElement.style.top;
Expand Down Expand Up @@ -222,6 +218,7 @@ export default function useAlign(
};
}
const popupRect = popupElement.getBoundingClientRect();
const { height, width } = win.getComputedStyle(popupElement);
Copy link
Member

Choose a reason for hiding this comment

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

Could you add some more comments to this to explain why this line was moved down?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I apply the code in antd side found this will not help on scroll bar trigger:

Kapture.2025-05-20.at.11.09.17.mp4

size not change for the adjust:

截屏2025-05-20 11 12 19

ref: ant-design/ant-design#53396

Copy link
Author

Choose a reason for hiding this comment

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

@zombieJ Can you please expand on this? I'm not sure how this impacts this PR or if there is any action required from me to get this fix in.

Copy link
Member

Choose a reason for hiding this comment

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

Can you please expand on this? I'm not sure how this impacts this PR or if there is any action required from me to get this fix in.

What he means is that your PR does not seem to have made any fixes, and the effect is the same as before.

Copy link
Member

Choose a reason for hiding this comment

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

As patched console snapshot above, the edge case is that align on the same case the size is same before your code adjust and after code adjust. The glitch is after the align screen trigger scrollbar and make the content collapse.

Copy link
Author

Choose a reason for hiding this comment

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

This PR is a fix for #496

Before these changes:

trigger-before.mp4

After these changes:

trigger-after-2.mp4

popupRect.x = popupRect.x ?? popupRect.left;
popupRect.y = popupRect.y ?? popupRect.top;
const {
Expand Down
Loading