create-figma-plugin icon indicating copy to clipboard operation
create-figma-plugin copied to clipboard

Selection quirk in dropdown when using preact/compat

Open gluck opened this issue 3 years ago • 2 comments

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

gluck avatar Jun 07 '22 08:06 gluck

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!

airtable-JayRansijn avatar Nov 08 '22 18:11 airtable-JayRansijn

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

HelixMorphe avatar Jun 20 '23 17:06 HelixMorphe