Skip to content

Escape and overlays in a dialog ​

One Escape closes one overlay: the topmost one. A select menu, a date picker, a menu or a tooltip open inside a dialog closes on the first Escape, and the dialog stays open; the next Escape runs the dialog's defaultReject action. A dialog opened from a dialog closes on its own Escape, and the dialog under it is shown again.

Overlays inside a dialog
A select, a date picker, a menu, a tooltip, a rich text editor and a dialog opened from this dialog. Escape closes the topmost of them.
Dialog without a reject action
Its only action is Done. It has no close button in the title bar, and Escape does nothing.

What the demo shows ​

  • Select and date picker - open the Colour menu or the Due date picker and press Escape: the menu or the picker closes. A second Escape cancels the dialog.
  • Menu and tooltip - a v-menu opened from the Menu button, and the tooltip of the Tooltip button, close on Escape in the same way.
  • Enter on a focused control - Tab to the Menu button and press Enter: the menu opens and the dialog stays. Enter on a focused Cancel or OK button runs that button's action; the result counts the actions run.
  • Rich text editor - a menu of the editor's toolbar closes on Escape; with no menu open, Escape in the editor cancels the dialog.
  • Nested dialog - Open Nested Dialog opens a modal.yesNo() above the template dialog. Escape answers it with no, and the template dialog is shown again.
  • No reject action - the Done dialog has no defaultReject action, so it has no close button in its title bar and Escape leaves it open. Enter runs Done.

<df-modal> lists the rules.

Released under the MIT License.