Skip to content

ComboBox: selectionMode="multiple" + allowsCustomValue clears all selected keys on Escape, Enter, and Tab #9837

@supertosse

Description

@supertosse

Provide a general summary of the issue here

When a ComboBox is configured with both selectionMode="multiple" and allowsCustomValue,
all previously selected keys are cleared if the user types something in the input and then
presses Escape, Enter, or Tab.

🤔 Expected Behavior?

Pressing Escape, Enter, or Tab should close/commit the input without affecting previously
selected items. The selected keys should remain unchanged unless the user explicitly
deselects an item.

😯 Current Behavior

After typing in the input:

  • Pressing Escape clears all selected keys (resets selection to empty)
  • Pressing Enter clears all selected keys
  • Pressing Tab clears all selected keys

This does not occur when allowsCustomValue is omitted — the bug is specific to the
combination of selectionMode="multiple" + allowsCustomValue.

💁 Possible Solution

No response

🔦 Context

No response

🖥️ Steps to Reproduce

  1. Render a ComboBox with selectionMode="multiple" and allowsCustomValue
  2. Select two or more items (e.g. Norway and Sweden)
  3. Click the input and type any partial string (e.g. "den")
  4. Press Escape (or Enter, or Tab)

Expected: selected keys remain [no, se]
Actual: selected keys are cleared (empty selection)

Minimal reproduction:

  import { Button, ComboBox, ComboBoxValue, Input, Label, ListBox, ListBoxItem, Popover } from 'react-aria-components';

  const countries = [
    { id: 'no', label: 'Norway' },
    { id: 'se', label: 'Sweden' },
    { id: 'dk', label: 'Denmark' },
  ];

  function Example() {
    return (
      <ComboBox
        selectionMode="multiple"
        defaultValue={['no', 'se']}
        allowsCustomValue
      >
        <Label>Country</Label>
        <div style={{ display: 'flex' }}>
          <Input />
          <Button>▼</Button>
        </div>
        <ComboBoxValue>
          {({ selectedItems, isPlaceholder }) =>
            isPlaceholder
              ? 'None selected'
              : `Selected: ${selectedItems.map(item => item?.id).join(', ')}`
          }
        </ComboBoxValue>
        <Popover>
          <ListBox items={countries}>
            {item => <ListBoxItem id={item.id}>{item.label}</ListBoxItem>}
          </ListBox>
        </Popover>
      </ComboBox>
    );
  }

Version

1.16.0

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

macOS

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    🩺 To Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions