DEV: Fix edit nav menu modals not appearing on mobile (#22403)

What is the problem?

This regressed in fe294ab1a77c1026b6996550eb8c36b6f07e1b73 and we did
not have any tests on mobile to catch the regression. The problem was
that we were conditionally rendering the edit nav menu modals component
in the sidebar. However, the sidebar is collapsed on mobile when a
button is clicked. When the sidebar collapses, the edit nav menu modals
ended up being destroyed with it.
This commit is contained in:
Alan Guo Xiang Tan
2023-07-04 11:11:47 +08:00
committed by GitHub
parent fe294ab1a7
commit 6ae4d6cd4c
7 changed files with 130 additions and 92 deletions

View File

@ -3,6 +3,10 @@
module PageObjects
module Components
class Sidebar < PageObjects::Components::Base
def open_on_mobile
click_button("toggle-hamburger-menu")
end
def visible?
page.has_css?("#d-sidebar")
end
@ -69,10 +73,12 @@ module PageObjects
find("#discourse-modal-title")
end
SIDEBAR_WRAPPER_SELECTOR = ".sidebar-wrapper"
def has_section?(name)
find(SIDEBAR_WRAPPER_SELECTOR).has_button?(name)
has_css?(".sidebar-sections [data-section-name='#{name.parameterize}']")
end
def has_no_section?(name)
has_no_css?(".sidebar-sections [data-section-name='#{name.parameterize}']")
end
def has_categories_section?
@ -103,10 +109,6 @@ module PageObjects
expect(tag_section_links.map(&:text)).to eq(tag_names)
end
def has_no_section?(name)
find(SIDEBAR_WRAPPER_SELECTOR).has_no_button?(name)
end
def primary_section_links(slug)
all("[data-section-name='#{slug}'] .sidebar-section-link-wrapper").map(&:text)
end