Skip to content

Select/useSelectState - Add option to not auto close when value is selected #8729

@acr92

Description

@acr92

Provide a general summary of the feature here

Currently useSelectState will auto close the select when an option is selected. In one of our design system components we need to allow the user to select a value, and then click a confirmation button to confirm the selection, but that is not possible without hacks.

🤔 Expected Behavior?

We would like to opt-out of auto closing the popover (or useSelectState could take the useOverlayTriggerState value as a prop and we could hook into it there)

😯 Current Behavior

onSelectionChange: (key) => {
if (props.onSelectionChange != null) {
props.onSelectionChange(key);
}
triggerState.close();
validationState.commitValidation();
}

when a value is selected the popover is closed.

💁 Possible Solution

Ideally just a prop to opt-out of this behaviour. I've attached our current workaround, which just involves a ref and hooking into callbacks and ignoring them, but it feels a bit nasty.

🔦 Context

Here is how we've solved it for now:

ContentSelect.tsx

💻 Examples

This is the component we want to build:
Image

🧢 Your Company/Team

Flowcase

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions