Skip to content
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

@rc-component/trigger doesn't work with portals #434

Open
Ke1sy opened this issue Oct 20, 2023 · 9 comments
Open

@rc-component/trigger doesn't work with portals #434

Ke1sy opened this issue Oct 20, 2023 · 9 comments

Comments

@Ke1sy
Copy link

Ke1sy commented Oct 20, 2023

After update from v1.14.2 to v1.14.3 I noticed that @rc-component/trigger doesn't work good with portals as previously.
We use the react-select with portal inside the antd Table filter dropdown ([email protected]). Filter dropdown has the search value as well as "Filter" and "Clear" buttons.
image

To apply the filter user should select option and type search value and click "Filter". But we faced the issues with select (react-select) that uses portals after @rc-component/trigger was updated to v1.14.3 or higher.

Expected behaviour:
After selecting the option, the dropdown is not closed and user can continue set up the filter.

Codesandbox with v1.14.2:
https://codesandbox.io/s/filter-and-sorter-antd-5-10-0-forked-lygdxm?file=/demo.tsx

Actual behaviour:
After selecting the option, the dropdown is closed and user cannot continue set up the filter.

Codesandbox with v1.14.3:
https://codesandbox.io/s/filter-and-sorter-antd-5-10-0-forked-q6h9s9?file=/demo.tsx

We believe that this issue is caused by these changes 854325f.

CC: @mellis481

@mellis481
Copy link

@afc163 @zombieJ @MadCcc Can you please take a look at this issue and advise what you'd like to be done? To summarize, PR #412 (specifically the enabling of capture mode for the mousedown event handler - https://github.com/react-component/trigger/blob/master/src/hooks/useWinClick.ts#L33) has broken Ant Design Table instances using the filterDropdown prop when using portals.

@afc163
Copy link
Member

afc163 commented Sep 3, 2024

@linxianxi Could you look into this one?

#412

@mellis481
Copy link

@linxianxi Can you please look at this issue?

@linxianxi
Copy link
Contributor

I have not used react-select and do not understand how it is implemented.

@Ke1sy
Copy link
Author

Ke1sy commented Sep 25, 2024

@linxianxi
I created another example using ReactDOM.createPortal that follows the logic that implemented in react-select.
image
Steps to reproduce:

  1. Open filter.
  2. Click on Portalled Menu (html and styles are hardcoded here, but in a real example it is a select list that allows to select the value).
    In v1.14.2 after we click on portalled menu the filter doesn't close ( https://codesandbox.io/p/sandbox/filter-and-sorter-antd-5-10-0-forked-9w6zz7 ).
    While in v1.14.3 the filter closes. ( https://codesandbox.io/p/sandbox/filter-and-sorter-antd-5-10-0-forked-qq4njt )
    CC: @mellis481 @afc163

@mellis481
Copy link

@linxianxi Did you have a chance to look at this problem?

@mellis481
Copy link

@afc163 What would you like to do with this issue? It doesn't seem like the person who created the PR that caused this regression is willing to address it.

To summarize, PR #412 (specifically the enabling of capture mode for the mousedown event handler - https://github.com/react-component/trigger/blob/master/src/hooks/useWinClick.ts#L33) has broken Ant Design Table instances using the filterDropdown prop when using portals.

@linxianxi
Copy link
Contributor

linxianxi commented Oct 18, 2024

I think this behavior is expected
You can try mui, which is the same as antd. Both antd's Select and mui's Select work properly. https://codesandbox.io/p/sandbox/bold-fire-vgpqq7?file=%2Fsrc%2FDemo.tsx%3A50%2C16

@Ke1sy
Copy link
Author

Ke1sy commented Oct 18, 2024

@linxianxi MUI is implemented in different way, there is a MuiBackdrop-root (fixed div) over the content with fixed position, that prevents the content of react-select menu to be reached. We can see that react-select menu is not focusable/hoverable and the event doesn't reach the select menu on click. rc-trigger doesn't use such mask (like MuiBackdrop) and allow the event to reach the select
image

To allow the event reach the react-select in MUI, I set the height of mask to 200px.
The result: the event reaches the react-select, the dropdown is not closed after click.

select.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants