Skip to content

[RAC ComboBox] onSelectionChange is called extra times when focus is changed after selection (fully controlled)Β #9727

@henkkasoft

Description

@henkkasoft

Provide a general summary of the issue here

react-aria-components ComboBox will be called first when option is selected and then one or two times again when focus is changed from component.
If the focus is removed by clicking somewhere else in the app, then there is 1 extra onSelectionChange call.
If the focus is removed by pressing tab, then there is 2 extra onSelectionChange calls.

This happens when fully controlled is used so that both selectedKey and inputValue are used.

πŸ€” Expected Behavior?

There should not be any extra onSelectionChange calls when focus is removed.

My core problem is that I want to reset selection when the same option is selected again but these extra onSelectionChange calls prevent me for adding this logic there.

😯 Current Behavior

There are 1 or 2 extra onSelectionChange calls when focus is removed.

πŸ’ Possible Solution

No response

πŸ”¦ Context

No response

πŸ–₯️ Steps to Reproduce

Here is codesandbox. Select option from combobox and press tab or mouse somewhere else and you can see the Call Count increased.
https://codesandbox.io/p/sandbox/tz7qjv

Version

react-aria-components 1.15.1

What browsers are you seeing the problem on?

Firefox, Chrome

If other, please specify.

No response

What operating system are you using?

Windows 10

🧒 Your Company/Team

No response

πŸ•· Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions