create-figma-plugin
create-figma-plugin copied to clipboard
Selection quirk in dropdown when using preact/compat
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

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!
How do I solve this in my plugin ? @yuanqing @gluck . Thanks in advance guys.