UX: replaces custom more menu by d-menu (#29090)

One of the big advantages is a nicer menu on mobile.

This commit also fixes a bug where the close modal action was called for any destroyed d-menu trigger, even if this specific menu was not expanding, which means it was closing a different modal than its own modal, given we can only have one modal at a time.
This commit is contained in:
Joffrey JAFFEUX
2025-01-20 12:00:11 +01:00
committed by GitHub
parent 2c81e24bca
commit 89ff7d51e6
25 changed files with 206 additions and 205 deletions

View File

@ -34,14 +34,14 @@ module PageObjects
I18n.t("js.sidebar.sections.community.edit_section.sidebar"),
)
expect(community_section).to have_no_css(".sidebar-more-section-links-details")
expect(community_section).to have_no_css(".sidebar-more-section-content")
PageObjects::Modals::SidebarSectionForm.new
end
def click_community_section_more_button
community_section.click_button(class: "sidebar-more-section-links-details-summary")
expect(community_section).to have_css(".sidebar-more-section-links-details")
community_section.click_button(class: "sidebar-more-section-trigger")
expect(community_section).to have_css(".sidebar-more-section-content")
self
end

View File

@ -61,6 +61,37 @@ describe "Viewing sidebar as logged in user", type: :system do
end
end
describe "when viewing the 'more' content in the Community sidebar section" do
let(:more_trigger_selector) do
".sidebar-section[data-section-name='community'] .sidebar-more-section-trigger"
end
let(:more_links_selector) do
".sidebar-section[data-section-name='community'] .sidebar-more-section-content"
end
it "toggles the more menu and handles click outside to close it" do
visit("/latest")
find(more_trigger_selector).click
expect(page).to have_selector(more_links_selector, visible: true)
expect(page).to have_selector("#{more_trigger_selector}[aria-expanded='true']")
find(more_trigger_selector).click
expect(page).not_to have_selector(more_links_selector)
expect(page).to have_selector("#{more_trigger_selector}[aria-expanded='false']")
find(more_trigger_selector).click
find(".d-header-wrap").click
expect(page).not_to have_selector(more_links_selector)
end
end
describe "when viewing the tags section" do
fab!(:tag1) do
Fabricate(:tag, name: "tag 1", description: "tag 1 description <script>").tap do |tag|