dequelabs / dequelabs/cauldron

Combobox: Include formValue in onSelectionChange callback

Open
#1,301 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
127
Forks
31
Avg merge
2d 12h
Merged PRs (30d)
8

Description

## Context

Currently, the `Combobox` component allows you to specify a `formValue` for `ComboboxItem`'s. However, there's not a great way to get the `formValue` of the currently selected item, since it's just rendered as a hidden form value prop.

The current work around is to either map the combobox value back to the list of form values, or to parse the form contents. It would be helpful if the selected combobox item's form value was included in the object passed to the `onSelectionChange` callback: https://github.com/dequelabs/cauldron/blob/6dd5a3404e743f0ec246056c2fe81666e064ce1c/packages/react/src/components/Combobox/Combobox.tsx#L332-L336

## Acceptance Criteria

When the `Combobox` selection changes and the `ComboboxItem` has a `formValue`, the `formValue` (and ideally the "previous" `formValue` for consistency) is provided:

```ts
onSelectionChange?.({
target,
value: stringValue,
previousValue: previousValue?.toString(),
formValue,
previousFormValue
});
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.