From 1127f0efcbdfad09ece65b0e989db80fcaa09bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Fri, 13 Aug 2021 13:10:34 +0200 Subject: [PATCH] docs: add escape event handler for closing tippy, see #1282 --- docs/src/demos/Examples/Community/React/index.jsx | 6 ++++++ docs/src/demos/Examples/Community/Vue/index.vue | 6 ++++++ docs/src/demos/Experiments/Commands/index.vue | 6 ++++++ docs/src/demos/Nodes/Mention/index.vue | 6 ++++++ 4 files changed, 24 insertions(+) diff --git a/docs/src/demos/Examples/Community/React/index.jsx b/docs/src/demos/Examples/Community/React/index.jsx index f6ca7cce..5c51cf54 100644 --- a/docs/src/demos/Examples/Community/React/index.jsx +++ b/docs/src/demos/Examples/Community/React/index.jsx @@ -59,6 +59,12 @@ export default () => { }) }, onKeyDown(props) { + if (props.event.key === 'Escape') { + popup[0].hide() + + return true + } + return reactRenderer.ref?.onKeyDown(props) }, onExit() { diff --git a/docs/src/demos/Examples/Community/Vue/index.vue b/docs/src/demos/Examples/Community/Vue/index.vue index 5f5d269b..5da67680 100644 --- a/docs/src/demos/Examples/Community/Vue/index.vue +++ b/docs/src/demos/Examples/Community/Vue/index.vue @@ -110,6 +110,12 @@ export default { }) }, onKeyDown(props) { + if (props.event.key === 'Escape') { + popup[0].hide() + + return true + } + return component.ref?.onKeyDown(props) }, onExit() { diff --git a/docs/src/demos/Experiments/Commands/index.vue b/docs/src/demos/Experiments/Commands/index.vue index 7eb17dda..661b809e 100644 --- a/docs/src/demos/Experiments/Commands/index.vue +++ b/docs/src/demos/Experiments/Commands/index.vue @@ -105,6 +105,12 @@ export default { }) }, onKeyDown(props) { + if (props.event.key === 'Escape') { + popup[0].hide() + + return true + } + return component.ref?.onKeyDown(props) }, onExit() { diff --git a/docs/src/demos/Nodes/Mention/index.vue b/docs/src/demos/Nodes/Mention/index.vue index b22530c0..3619a5ac 100644 --- a/docs/src/demos/Nodes/Mention/index.vue +++ b/docs/src/demos/Nodes/Mention/index.vue @@ -69,6 +69,12 @@ export default { }) }, onKeyDown(props) { + if (props.event.key === 'Escape') { + popup[0].hide() + + return true + } + return component.ref?.onKeyDown(props) }, onExit() {