diff options
author | Anastasia Smirnova <anasmi@utu.fi> | 2019-12-05 20:33:31 +0200 |
---|---|---|
committer | Tatu Lund <tatu@vaadin.com> | 2019-12-05 20:33:31 +0200 |
commit | 877d7ef7ce3e29905e55fd36ee2d3ac8cf77ccf6 (patch) | |
tree | a8f0ed16add99eff11dbbe21c39df4eb6a24855f /client/src | |
parent | 7895a74211c12a45e614892ce3e24fba838186fd (diff) | |
download | vaadin-framework-877d7ef7ce3e29905e55fd36ee2d3ac8cf77ccf6.tar.gz vaadin-framework-877d7ef7ce3e29905e55fd36ee2d3ac8cf77ccf6.zip |
Close window on ESC, when maximized button is clicked (#11840)
Fixes #11838
Changes:
1. Close a window when maximized button is focused and ESC is pressed
2. Add additional check for a close button to react to the ESC key press
3. Rename a private method `onCloseClick` to `closeWindow` to allow code re-use
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/main/java/com/vaadin/client/ui/VWindow.java | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VWindow.java b/client/src/main/java/com/vaadin/client/ui/VWindow.java index e19a13c005..03cb7e16bf 100644 --- a/client/src/main/java/com/vaadin/client/ui/VWindow.java +++ b/client/src/main/java/com/vaadin/client/ui/VWindow.java @@ -1014,14 +1014,20 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, // if clicked or key ENTER or SPACE is pressed } else if (isClosable() && target == closeBox) { if (type == Event.ONCLICK || (type == Event.ONKEYUP - && isKeyEnterOrSpace(event.getKeyCode()))) { - onCloseClick(); + && (isKeyEnterOrSpace(event.getKeyCode())) + || event.getKeyCode() == KeyCodes.KEY_ESCAPE)) { + closeWindow(); } bubble = false; } else if (target == maximizeRestoreBox) { + // if ESC is pressed, close the window + if (type == Event.ONKEYUP + && event.getKeyCode() == KeyCodes.KEY_ESCAPE) { + closeWindow(); + } // handled in connector // if clicked or key ENTER or SPACE is pressed - if (type != Event.ONCLICK && !(type == Event.ONKEYUP + else if (type != Event.ONCLICK && !(type == Event.ONKEYUP && isKeyEnterOrSpace(event.getKeyCode()))) { bubble = false; } @@ -1097,7 +1103,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, } } - private void onCloseClick() { + private void closeWindow() { // Send the close event to the server client.updateVariable(id, "close", true, true); } |