From f1849199e95b8785d97ddb5dcc124bcaaec6cd83 Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Mon, 18 Nov 2024 15:43:36 -0500 Subject: [PATCH] A11Y: Allow dismissing the discard drafts modal via keyboard (#29802) --- .../app/components/modal/discard-draft.gjs | 2 +- .../tests/acceptance/composer-test.js | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/app/components/modal/discard-draft.gjs b/app/assets/javascripts/discourse/app/components/modal/discard-draft.gjs index ee55f42e8dc..2ca560daa87 100644 --- a/app/assets/javascripts/discourse/app/components/modal/discard-draft.gjs +++ b/app/assets/javascripts/discourse/app/components/modal/discard-draft.gjs @@ -21,7 +21,7 @@ export default class DiscardDraftModal extends Component { <:body>
diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-test.js index b6d57ed8b39..9902f4da1c3 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-test.js @@ -994,6 +994,31 @@ acceptance("Composer", function (needs) { await click(".save-or-cancel .cancel"); assert.dom(".discard-draft-modal .save-draft").exists(); }); + + test("Discard drafts modal can be dismissed via keyboard", async function (assert) { + await visit("/t/internationalization-localization/280"); + await click("#topic-footer-buttons .create"); + + await fillIn(".d-editor-input", "[quote]some quote[/quote]"); + + await click(".save-or-cancel .cancel"); + assert.dom(".discard-draft-modal .save-draft").exists(); + + await triggerKeyEvent( + ".discard-draft-modal .save-draft", + "keydown", + "Escape" + ); + + assert.dom(".discard-draft-modal").doesNotExist(); + + assert + .dom(".d-editor-input") + .hasValue( + "[quote]some quote[/quote]", + "composer textarea is not cleared" + ); + }); }); acceptance("Composer - Customizations", function (needs) {