A platform for community discussion. Free, open, simple.
FIX: Allow typing inside float-kit menus rendered from within a modal (#39370)
Régis Hanol630c295cdb7f
diff --git a/frontend/discourse/app/components/d-modal.gjs b/frontend/discourse/app/components/d-modal.gjsindex 77020622620..a3b37103268 100644--- a/frontend/discourse/app/components/d-modal.gjs+++ b/frontend/discourse/app/components/d-modal.gjs@@ -226,8 +226,15 @@ export default class DModal extends Component {return;}- // Prevent keyboard events from leaking to elements behind the modal- if (!this.wrapperElement.contains(document.activeElement)) {+ // Prevent keyboard events from leaking to elements behind the modal.+ // Allow events when focus is inside a float-kit portal (menu/tooltip)+ // opened from this modal, since those render outside the modal DOM.+ if (+ !this.wrapperElement.contains(document.activeElement) &&+ !document.activeElement?.closest(+ ".fk-d-menu, .fk-d-menu-modal, .fk-d-tooltip"+ )+ ) {event.stopPropagation();event.preventDefault();}diff --git a/spec/system/custom_sidebar_sections_spec.rb b/spec/system/custom_sidebar_sections_spec.rbindex 01ecc0afa3b..1065361d648 100644--- a/spec/system/custom_sidebar_sections_spec.rb+++ b/spec/system/custom_sidebar_sections_spec.rb@@ -176,6 +176,18 @@ describe "Custom sidebar sections" doexpect(sidebar).to have_section_link("Faq", target: "_self", href: "/faq#someheading")end+ it "allows typing in the icon picker filter input" do+ sign_in user+ visit("/latest")+ sidebar.click_add_section_button++ picker = section_modal.first_link_icon_picker+ picker.expand.type_filter("globe")++ expect(picker.filter_input.value).to eq("globe")+ expect(picker).to have_icon("globe")+ end+it "accessibility - when new row is added in custom section, first new input is focused" dosign_in uservisit("/latest")diff --git a/spec/system/page_objects/components/d_icon_grid_picker.rb b/spec/system/page_objects/components/d_icon_grid_picker.rbindex 35bd87d5a96..67a1d77b828 100644--- a/spec/system/page_objects/components/d_icon_grid_picker.rb+++ b/spec/system/page_objects/components/d_icon_grid_picker.rb@@ -9,6 +9,7 @@ module PageObjectsdef expandtrigger.click+ selfenddef select_icon(icon_id)@@ -20,7 +21,20 @@ module PageObjectsenddef filter(term)- find(".d-icon-grid-picker__filter .filter-input").fill_in(with: term)+ filter_input.fill_in(with: term)+ end++ def type_filter(term)+ filter_input.send_keys(term)+ self+ end++ def filter_input+ find(".d-icon-grid-picker__filter .filter-input")+ end++ def has_icon?(icon_id)+ page.has_css?("[data-icon-id='#{icon_id}']")enddef cleardiff --git a/spec/system/page_objects/modals/sidebar_section_form.rb b/spec/system/page_objects/modals/sidebar_section_form.rbindex dce44488bd9..9b7a5896924 100644--- a/spec/system/page_objects/modals/sidebar_section_form.rb+++ b/spec/system/page_objects/modals/sidebar_section_form.rb@@ -10,13 +10,18 @@ module PageObjectsdef fill_link(name, url, icon = "link")fill_in("link-name", with: name, match: :first)fill_in("link-url", with: url, match: :first)- first_link = find(".sidebar-section-form-link", match: :first)- icon_picker = PageObjects::Components::DIconGridPicker.new(first_link)+ icon_picker = first_link_icon_pickericon_picker.expandicon_picker.filter(icon)icon_picker.select_icon(icon)end+ def first_link_icon_picker+ PageObjects::Components::DIconGridPicker.new(+ find(".sidebar-section-form-link", match: :first),+ )+ end+def mark_as_publicfind(".modal .mark-public").clickend