Skip to content

Commit

Permalink
feat(onboarding): close on esc key press
Browse files Browse the repository at this point in the history
  • Loading branch information
harunbleech committed Nov 28, 2024
1 parent 31b05cb commit 0cd0d5b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions assets/scripts/onboarding.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
}
Expand Down

0 comments on commit 0cd0d5b

Please sign in to comment.