FIX: Keyboard shortcuts closing table builder modal (#26278)

This commit is contained in:
Keegan George 2024-03-21 10:50:25 -07:00 committed by GitHub
parent 2b4eb36a97
commit 2129e9e37a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import DModalCancel from "discourse/components/d-modal-cancel";
import TextField from "discourse/components/text-field";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import KeyboardShortcuts from "discourse/lib/keyboard-shortcuts";
import {
arrayToTable,
findTableRegex,
@ -30,6 +31,12 @@ export default class SpreadsheetEditor extends Component {
constructor() {
super(...arguments);
this.loadJspreadsheet();
KeyboardShortcuts.pause();
}
willDestroy() {
super.willDestroy(...arguments);
KeyboardShortcuts.unpause();
}
get modalAttributes() {

View File

@ -142,5 +142,17 @@ describe "Table Builder", type: :system do
expect(page).to have_css(".dialog-container .dialog-content")
end
end
it "should not accept default Discourse keyboard shortcuts" do
# Some default keyboard shortcuts like Shift + S bring up a modal overriding
# the table builder modal and therefore should not be accepted
topic_page.visit_topic(topic)
topic_page.find(".btn-edit-table", visible: :all).click
insert_table_modal.find_cell(0, 0)
insert_table_modal.send_keys(:shift, "s")
expect(page).to have_css(".insert-table-modal")
expect(page).to have_no_css(".share-topic-modal")
end
end
end