Skip to content

[multi-select-combo-box] Input value cleared automatically when combining data provider and auto open disabled #3969

Closed

Description

@sissbruecker

Description

When using an async data provider and disabling auto open, any input is cleared automatically when the data provider responds with data. That basically makes it impossible to enter a value manually.

Demo (data provider has a delay of 1 second):

Bildschirmaufnahme.2022-05-30.um.15.26.20.mp4

Expected outcome

The input value should not be altered.

Minimal reproducible example

<vaadin-multi-select-combo-box></vaadin-multi-select-combo-box>
const comboBox = document.querySelector('vaadin-multi-select-combo-box');
comboBox.itemIdPath = 'id';
comboBox.itemLabelPath = 'name';
comboBox.itemValuePath = 'id';
comboBox.autoOpenDisabled = true;

const items = [
  { id: 1, name: 'Hydrogen' },
  { id: 2, name: 'Helium' },
  { id: 3, name: 'Lithium' },
  { id: 4, name: 'Beryllium' },
  { id: 5, name: 'Boron' },
  { id: 6, name: 'Carbon' },
  { id: 7, name: 'Nitrogen' },
  { id: 8, name: 'Oxygen' },
  { id: 9, name: 'Fluorine' }
];
comboBox.dataProvider = ({filter}, callback) => {
  const filteredItems = items.filter(item => item.name.toLowerCase().includes(filter.toLowerCase()))
  setTimeout(() => {
    callback(filteredItems, filteredItems.length);
  }, 1000)
}

Steps to reproduce

  1. Focus the input
  2. Enter something like Heli
  3. Wait for the data provider to respond
  4. Notice how the input value is cleared

Environment

Vaadin version(s): 23.1.0-rc2

Browsers

Issue is not browser related

Activity

  1. sissbruecker commented on May 30, 2022

    @sissbruecker
    MemberAuthor

    The issue seems to be this condition in the data provider mixin, which tries to commit the value if the combo box is closed and does not have focus (i.e. user is not interacting with it anymore):

    if (!this.opened && !this.hasAttribute('focused')) {
    this._commitValue();
    }

    This doesn't work because focused is not set on the internal combo box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions