yuanqing / create-figma-plugin

:battery: The comprehensive toolkit for developing plugins and widgets for Figma and FigJam
https://yuanqing.github.io/create-figma-plugin/
MIT License
947 stars 91 forks source link

Selection quirk in dropdown when using preact/compat #108

Open gluck opened 2 years ago

gluck commented 2 years ago

When using preact/compat (i.e. when any dependency uses React directly), onFocus event will bubble (to match React behavior): https://github.com/preactjs/preact/pull/3355

For dropdown this will cause a selection bug (mousedown on an item will trigger onFocus on the menu item, which will bubble up to the dropdown, which will call setSelected with the previous selected item, which will be highlighted instead until mouseup).

https://github.com/yuanqing/create-figma-plugin/blob/main/packages/ui/src/components/dropdown/dropdown.tsx#L111-L128

Probably many ways to fix that, here's the one I went with: https://github.com/divriots/create-figma-plugin-ui/commit/b7ffa1738ebe6859eb4c5aefa2b73dbbe9adcce3

dropdown_quirk

airtable-JayRansijn commented 2 years ago

I was running into this as well, and took me a while to realize it was the dropdown and not my app logic. Thanks for logging this!

HelixMorphe commented 1 year ago

How do I solve this in my plugin ? @yuanqing @gluck . Thanks in advance guys.