Steps to Reproduce
- Open this sandbox. It uses UUI v.5.9.1
- Click on the "Open dropdown" button
- Click on the "Example 1" option. This will update the local state's value and close the dropdown using the
bodyProps.onClose callback
- The state's update is wrapped in
flushSync to ensure that the update happens before the dropdown is closed
- Check the console
- Change the version of UUI packages in
package.json to 6.0.0 or later and reinstall dependencies via console (pnpm install)
- Repeat steps 2-4
Actual result
In the 5.9.1 version, when the dropdown is closed, the onValueChange and onClose callbacks of the Dropdown component have access to the latest value of the local state. Thus, they log to the console "example-1".
In the 6.0.0 or later versions, when the dropdown is closed, the onValueChange and onClose callbacks of the Dropdown component have access only to the initial value of the local state. Thus, they log to the console undefined.
Expected result
The behavior should be the same as in 5.9.1.
Additional information
Steps to Reproduce
bodyProps.onClosecallbackflushSyncto ensure that the update happens before the dropdown is closedpackage.jsonto 6.0.0 or later and reinstall dependencies via console (pnpm install)Actual result
In the 5.9.1 version, when the dropdown is closed, the
onValueChangeandonClosecallbacks of theDropdowncomponent have access to the latest value of the local state. Thus, they log to the console"example-1".In the 6.0.0 or later versions, when the dropdown is closed, the
onValueChangeandonClosecallbacks of theDropdowncomponent have access only to the initial value of the local state. Thus, they log to the consoleundefined.Expected result
The behavior should be the same as in 5.9.1.
Additional information
Dropdownhas been migrated to a function component