Key Shortcut does not work in Confirm Dialog

This is very weird behaviour as i can’t get any key shortcut to work in a vaadin dialog component.

    `confirmDialog.setConfirmButton(confirmButton);`
              `confirmButton.addClickShortcut(Key.KEY_J);`

even this fails to work

Shortcuts.addShortcutListener(UI.getCurrent(),()->confirmButton.click(),Key.KEY_J)
.listenOn(UI.getCurrent());

confirmButton.addClickShortcut(Key.KEY_J).listenOn(confirmDialog);
Should work

Thanks @quirky-zebra but this does not work , i even tried in vaadin 24.

public HelloWorldView() { sayHello = new Button("Say hello"); sayHello.addClickListener(ignore ->{ final var confirmDialog = new ConfirmDialog(); confirmDialog.setConfirmText("Please confirm"); confirmDialog.setCloseOnEsc(true); final var confirmButton = new Button("Confirm"); confirmButton.addClickShortcut(Key.KEY_J) .listenOn(confirmDialog); confirmDialog.setConfirmButton(confirmButton); confirmDialog.addConfirmListener(e->{ Notification.show("Confirmed"); }); confirmDialog.open(); }); add(sayHello); }

Workaround would be to use confirmDialog.setModal(false)

Could be a regression, this behavior was fixed last year https://github.com/vaadin/flow/issues/13205

can’t spot any public method .setModal(false) in ConfirmDialog

That makes it harder :grimacing: use a dialog instead…

@useful-whale fyi: looks like the confirm dialog is not on par with the dialog fixes regarding modularity

Hmm, it should be, since ConfirmDialog is an extension of Dialog :thinking:
And the fixes to that issue you linked are not specific fo Dialog but should apply to any modal container.
Strange. I’ll try to reproduce and create a ticket if I can.

In the meantime, you could try this workaround proposed in that fixed ticket: button.addClickShortcut(Key.ENTER).listenOn(dialog);

(ah, disregard that last part, I see you already do that)

ok yeah, can reproduce.
No idea if the issue is in ConfirmDialog or Flow, but I’ll make a ticket and we’ll see what happens :slightly_smiling_face:

Issue: https://github.com/vaadin/flow-components/issues/5389

Thanks @useful-whale

Aand it’s fixed. Should ship in the next patches for 23 and onward.

Thanks for the update