Skip to content

Commit

Permalink
577 close modals by esc-key (#585)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesDoberer authored Jun 24, 2019
1 parent 3488afc commit 65c19e2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,25 @@ describe('Luigi client ux manager features', () => {
.contains('Luigi confirmation modal has been confirmed');
});

it('Close Luigi Client generic confirmation modal by esc keypress', () => {
cy.goToUxManagerMethods($iframeBody);

cy.get('[data-cy=luigi-confirmation-modal]').should('not.be.visible');
cy.wrap($iframeBody)
.find('[data-cy=show-luigi-confirmation-modal]')
.click();
cy.get('[data-cy=luigi-confirmation-modal]').should('be.visible');

cy.get('[data-cy=luigi-modal-dismiss]').trigger('keydown', {
keyCode: 27,
which: 27
});
cy.get('[data-cy=luigi-confirmation-modal]').should('not.be.visible');
cy.wrap($iframeBody)
.find('[data-cy=luigi-confirmation-modal-result]')
.contains('Luigi confirmation modal has been dismissed');
});

it('loading indicator', () => {
Cypress.currentTest.retries(3);
cy.get('.fd-shellbar')
Expand Down
8 changes: 8 additions & 0 deletions core/src/ConfirmationModal.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<svelte:window on:keydown="handleKeydown(event)"/>
<div class="fd-ui__overlay fd-overlay fd-overlay--modal" aria-hidden="false">
<div class="fd-modal" data-cy="luigi-confirmation-modal">
<div class="fd-modal__content" role="document">
Expand Down Expand Up @@ -47,6 +48,13 @@ <h1 class="fd-modal__title">{settings.header}</h1>
} catch (e) {
console.warn("Couldn't focus confirmation button in modal");
}
},
methods: {
handleKeydown(event) {
if (event.keyCode === 27) {
this.fire('modalDismiss');
}
}
}
};
</script>
Expand Down
8 changes: 8 additions & 0 deletions core/src/Modal.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<svelte:window on:keydown="handleKeydown(event)"/>
<div class="fd-ui__overlay fd-overlay fd-overlay--modal" style="z-index:999">
<div class="fd-modal" data-e2e="modal-mf">
<div class="fd-modal__content" style="height:100%">
Expand Down Expand Up @@ -99,6 +100,13 @@ <h1 class="fd-modal__title">{modalSettings.title}</h1>
return {
isDataPrepared: false
};
},
methods: {
handleKeydown(event) {
if (event.keyCode === 27) {
this.fire('close');
}
}
}
};
</script>
Expand Down

0 comments on commit 65c19e2

Please sign in to comment.