trezor / trezor-suite

Trezor Suite Monorepo
https://trezor.io/trezor-suite
Other
713 stars 247 forks source link

Dropdown component flicks when specific spot is clicked #14898

Open krystxf opened 1 week ago

krystxf commented 1 week ago

Describe the bug Dropdown component flicks when specific spot is clicked. This is now happening only in storybook and not in the app, but it used to be in app as well.

Info:

How to reproduce Steps to reproduce the behavior:

  1. run packages/components storybook
  2. open http://localhost:9003/?path=/story/dropdown--dropdown
  3. Click inside red rectangle, but outside of grey circle Where to click

Expected behavior Menu content doesn't flic

Screenshots

https://github.com/user-attachments/assets/5470fc67-f31e-41da-b73d-9bd06dc8ea8d

Additional context File with issue

krystxf commented 2 days ago

Cause

This is happening because there are different triggers for blur click and button click

Because of this two state changes are happening almost at the same time and asynchronous state updates causes flicker.

Solutions

  1. It is a quick solution, but it doesn't fix the main issue with the button "hitbox" change this onClick to onMouseDown and add onTouchStart as well
  2. fix the fundamental issue (more elegant logic, but is more complex) change button "hitbox" so that it doesn't trigger useOnClickOutside