@@ -16,7 +16,7 @@ import {keyCodeArrayToString, toTitleCase} from './keynames';
1616export class ShortcutDialog {
1717 outputDiv : HTMLElement | null ;
1818 modalContainer : HTMLElement | null ;
19- shortcutDialog : HTMLElement | null ;
19+ shortcutDialog : HTMLDialogElement | null ;
2020 open : Boolean ;
2121 closeButton : HTMLElement | null ;
2222 /**
@@ -81,13 +81,12 @@ export class ShortcutDialog {
8181
8282 toggle ( ) {
8383 if ( this . modalContainer && this . shortcutDialog ) {
84- this . modalContainer . classList . toggle ( 'open' , ! this . open ) ;
85- if ( this . open ) {
86- this . shortcutDialog . removeAttribute ( 'open' ) ;
84+ // Use built in dialog methods.
85+ if ( this . shortcutDialog . hasAttribute ( ' open' ) ) {
86+ this . shortcutDialog . close ( ) ;
8787 } else {
88- this . shortcutDialog . setAttribute ( 'open' , '' ) ;
88+ this . shortcutDialog . showModal ( ) ;
8989 }
90- this . open = ! this . open ;
9190 }
9291 }
9392
@@ -189,18 +188,6 @@ Blockly.Css.register(`
189188 --shortcut-modal-border-color: #9aa0a6;
190189}
191190
192- .modal-container {
193- align-items: center;
194- display: none;
195- font-family: Roboto;
196- height: 100%;
197- justify-content: center;
198- left: 0;
199- position: absolute;
200- top: 0;
201- width: 100%;
202- }
203-
204191.shortcut-modal {
205192 border: 1px solid var(--shortcut-modal-border-color);
206193 border-radius: 12px;
@@ -216,12 +203,11 @@ Blockly.Css.register(`
216203 z-index: 99;
217204}
218205
219- .modal-container.open,
220206.shortcut-modal[open] {
221207 display: flex;
222208}
223209
224- .modal-container .close-modal {
210+ .shortcut-modal .close-modal {
225211 border: 0;
226212 background: transparent;
227213 float: inline-end;
@@ -231,13 +217,22 @@ Blockly.Css.register(`
231217 right: 24px;
232218}
233219
234- .modal-container h1 {
220+ .shortcut-modal h1 {
235221 font-weight: 600;
236222 font-size: 1.2em;
237223}
238224
239- .modal-container {
225+ .shortcut-modal:before {
240226 background: radial-gradient(rgba(244, 244, 244, 0.43), rgba(75, 75, 75, 0.51));
227+ align-items: center;
228+ display: block;
229+ font-family: Roboto;
230+ height: 100%;
231+ justify-content: center;
232+ left: 0;
233+ position: absolute;
234+ top: 0;
235+ width: 100%;
241236}
242237
243238.shortcut-table {
0 commit comments