From 0cd0d5b17d7df00641dd7ea04a3c848a0333c184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harun=20Ba=C5=A1i=C4=87?= Date: Thu, 28 Nov 2024 17:47:20 +0100 Subject: [PATCH] feat(onboarding): close on esc key press --- assets/scripts/onboarding.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/assets/scripts/onboarding.js b/assets/scripts/onboarding.js index 23dc277..f60041a 100644 --- a/assets/scripts/onboarding.js +++ b/assets/scripts/onboarding.js @@ -68,6 +68,9 @@ if ( window.vrts_admin_vars.onboarding ) { onCloseClick: () => { onboarding.destroy(); }, + onDestroyed: () => { + window.removeEventListener( 'keyup', onKeyup ); + }, steps: window.vrts_admin_vars.onboarding.steps.map( ( step ) => { return { element: step.element, @@ -81,6 +84,14 @@ if ( window.vrts_admin_vars.onboarding ) { } ), } ); + const onKeyup = ( event ) => { + if ( event.key === 'Escape' ) { + onboarding.destroy(); + } + }; + + window.addEventListener( 'keyup', onKeyup ); + onboarding.drive(); saveOnboarding(); }