Closed SpaNb4 closed 5 months ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
util | ❌ Failed (Inspect) | Dec 27, 2023 11:58am |
@MadCcc @zombieJ Could you please review this PR?
@MadCcc @afc163 @zombieJ Can you please review and merge this PR? It's critical for my team.
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
5a3231f
) 91.51% compared to head (105a436
) 91.54%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@MadCcc 看看这个
@MadCcc Could you please review this PR?
@MadCcc Bump.
@MadCcc Help!
@afc163 Can you please help get this PR merged?
ping @MadCcc @zombieJ
Could we add test for preact?
Checked for React 16, seems safe to merge.
Fixes the issue described in https://github.com/ant-design/ant-design/pull/44135
Why the issue exists: The highlighted code in
rc-dropdown
returnstrue
for react andfalse
for preact https://github.com/react-component/dropdown/blob/master/src/Overlay.tsx#L25Screenshot
![image](https://github.com/react-component/util/assets/69504277/e353950b-c911-48b8-a6dc-2497cc60a3b0)That's why the focus doesn't shift to the menu when using preact.
Now let's take a look at the
supportRef
code and add some console.log to it for debugging:Screenshot
![image](https://github.com/react-component/util/assets/69504277/bfc83dfc-3919-4fe5-810f-966c003eafb8)And here are the results:
react
![image](https://github.com/react-component/util/assets/69504277/f60fe8c2-e937-46de-94cd-60c598f7a73f)preact
![image](https://github.com/react-component/util/assets/69504277/218a2621-e37a-476e-b863-b6cdf6576a2d)So, based on the screenshots above, we can conclude that in the case of preact, the
nodeOrComponent
is afunction
, not anobject
, so the second condition is fulfilled andfalse
is returned.And to fix this I added an additional condition because in the screenshot above you can see that preact as well as react have a![image](https://github.com/react-component/util/assets/69504277/10829e5d-520f-4288-9926-8d18c2c582a5)
$$typeof
property equal toSymbol(react.forward_ref)