Skip to content

ComboBox calls CustomValueSetListener twice #2523

Closed

Description

@mstahv

Description

ComboBox calls CustomValueSetListener twice if a dialog is opened in the listener

Expected outcome

CustomValueSetListener is called once

Actual outcome

ComboBox calls CustomValueSetListener twice

Minimal reproducible example

package com.mycompany.v22.test;

import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.dialog.Dialog;
import com.vaadin.flow.component.html.Span;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.Route;

@Route
public class MainView extends VerticalLayout {

    private int dialogCounter = 1;
    
    public MainView() {

        ComboBox<String> cb = new ComboBox<>();

        cb.setLabel("Type something and hit enter");
        cb.addCustomValueSetListener(cv -> {
            System.err.println("WTF, i'm called twice ? " + cv.getDetail());
            Dialog d2 = new Dialog();
            
            d2.add(new Span("Dialog " + dialogCounter));
            dialogCounter++;

            Button save = new Button("Close");
            save.addClickListener(e1 -> {
                d2.close();
            });
            
            d2.add(save);

            d2.open();

        });

        add(cb);

    }
}

Steps to reproduce

Use the example code, type something to field and hit enter. You'll see two dialogs opened instead of one.

Environment

Vaadin
22.0.2
Flow
9.0.2
Java
Eclipse Adoptium 17
OS
aarch64 Mac OS X 12.0.1
Browser
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36

Browsers Affected

How would I know? I only have Safari and Chrome.

Activity

  1. web-padawan commented on Feb 21, 2022

    @web-padawan
    Member

    Duplicate of #2285.

  2. web-padawan commented on Feb 21, 2022

    @web-padawan
    Member

    Reopened as this appears to be a problem in the web component different from #2285.

  3. self-assigned this
    on Feb 21, 2022
  4. web-padawan commented on Feb 22, 2022

    @web-padawan
    Member

    The fix caused a regression in TimePicker and will be reverted. Reopening this until we find a better fix.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions