vaadin / vaadin/framework

ComboBox does not select value if User enters the value manually and TABs out fast

Open
#6,671 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Stale v7
Dominant language
Java
Stars
1.8k
Forks
717
Avg merge
2d 6h
Merged PRs (30d)
3

Description

Originally by jonas.hahn


Setup

Given is a Month-Combobox with Values from 01 to 12 and a Year-Combobox with Values from 2015-2025. Before and after the ComboBoxes are TextBoxes to simulate tabbing from/into another component. To verify the currently chosen Value a Label displays the ComboBox values and updates on change.

Problemcase

Our client's employees get routine in entering data and make use of TABbing from one field to the next one. If they enter a month e.g. 01 and press TAB directly after it the ComboBox does not record the value, but resets to the Prompt (MM) or the value which was entered before (e.g. going back into the field and changing a 04 to a 06 and TABbing on results in 04 still being the value of the ComboBox).

This only happens if entering the value and tabbing on are in very fast succession. If the connection is slow it happens more often.

Ideas

I assume the ComboBox is only able to select, if it has loaded its selections. Are there any suggestions for a workaround/fix?

#!java
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Label;
import com.vaadin.ui.TextField;

public class ComboBoxBug extends AbstractTestUI implements ValueChangeListener {

    private Label currentSelection = new Label();
    private ComboBox monthBox = new ComboBox();
    private ComboBox yearBox = new ComboBox();

    @Override
    protected void setup(VaadinRequest request) {

        monthBox.setInputPrompt("MM");
        monthBox.addValueChangeListener(this);

        for (int month = 1; month <= 12; month++) {
            monthBox.addItem(String.format("%02d", month));
        }

        yearBox.setInputPrompt("YYYY");
        yearBox.addValueChangeListener(this);

        for (int year = 2015; year <= 2025; year++) {
            yearBox.addItem(String.format("%04d", year));
        }
        addComponent(new TextField("Just a Placeholder"));
        addComponent(monthBox);
        addComponent(yearBox);
        addComponent(new TextField("Just a Placeholder"));
        addComponent(currentSelection);

    }

    @Override
    public void valueChange(ValueChangeEvent event) {
        currentSelection.setCaption(monthBox.getValue() + " "
                + yearBox.getValue());
    }

}

Imported from https://dev.vaadin.com/ issue #17676

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use the provided ComboBoxBug setup to reproduce entering a value and pressing TAB immediately, including the slower-connection case. Start by tracing the ComboBox input, loading, and focus/blur handling; done means the manually entered month or year is retained and the value-change display updates reliably after fast tabbing.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.