paragon icon indicating copy to clipboard operation
paragon copied to clipboard

`Dropdown` component's `onToggle` prop is only called on close, not on open.

Open adamstankiewicz opened this issue 3 years ago • 0 comments

The Dropdown component accepts an onToggle prop, however it is only called when the component is closed, not opened. Its intent, though, is to be called on open or on close, since the isOpen state variable is passed as a function argument to onToggle callback function.

In the handleToggle function, we do an early return preventing the onToggle callback function from being called: https://github.com/openedx/paragon/blob/5013f9a0304a04995a83da3535a8b7bc2fa67ae6/src/Dropdown/index.jsx#L44

AC

  • Verify onToggle is called both on open and on close, with the appropriate function arguments (e.g., isOpen should be false is the dropdown was just closed).
  • Ensure onToggle is part of the props API on the documentation website.

adamstankiewicz avatar Oct 11 '22 17:10 adamstankiewicz