Skip to content

[confirm-dialog] Confirm dialog closes on holding space #568

@yuriy-fix

Description

@yuriy-fix

Description of the bug (can be considered as edge case)

confirm-dialog is moving the focus to the confirmButton when opens. So in case it set to be opened on keydown, if you press and hold space for some time (it will start dispatching huge amount of keydown events), the dialog will be opened and on release (keyup is dispatched and click afterwards) the confirmButton will be clicked, so it will be closed right away.

Minimal reproducible example

<vaadin-button>Open dialog</vaadin-button>
<vaadin-confirm-dialog header="Meeting starting" confirm-text="OK">
  Your next meeting starts in 5 minutes
</vaadin-confirm-dialog>
const dialog = document.querySelector('vaadin-confirm-dialog');
const button = document.querySelector('vaadin-button');

button.addEventListener('keydown', function(event) {
  if (/^( |SpaceBar)$/.test(event.key)) {
    dialog.opened = true;
  }
});
  1. Use the code (modified demo example)
  2. Focus the Open dialog button, i.e. with Tab
  3. Hold Space
  4. Release once dialog is opened.

Expected behaviour

Dialog remains opened

opened-dialog

Actual behavior:

Dialog is auto-closed

closing-dialog

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