FIX: sidebar URL full reload when anchor (#23121)

Ember LinkTo is not accepting anchors.
In that case, we should treat those links as external, which will trigger full reload.
This commit is contained in:
Krzysztof Kotlarek 2023-08-24 08:39:30 +10:00 committed by GitHub
parent 92b2e10ee8
commit 10c25e9b86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -22,6 +22,7 @@ export default class SectionLink {
this.text = name;
this.value = value;
this.section = section;
this.withAnchor = value.match(/#\w+$/gi);
if (!this.externalOrFullReload) {
const routeInfoHelper = new RouteInfoHelper(router, value);
@ -36,7 +37,7 @@ export default class SectionLink {
}
get externalOrFullReload() {
return this.external || this.fullReload;
return this.external || this.fullReload || this.withAnchor;
}
@bind

View File

@ -95,6 +95,24 @@ describe "Custom sidebar sections", type: :system do
)
end
it "allows the user to create custom section with anchor" do
sign_in user
visit("/latest")
sidebar.click_add_section_button
expect(section_modal).to be_visible
expect(section_modal).to have_disabled_save
expect(sidebar.custom_section_modal_title).to have_content("Add custom section")
section_modal.fill_name("My section")
section_modal.fill_link("Faq", "/faq#anchor")
section_modal.save
expect(sidebar).to have_section("My section")
take_screenshot
expect(sidebar).to have_section_link("Faq", target: "_blank")
end
it "allows the user to edit custom section" do
sidebar_section = Fabricate(:sidebar_section, title: "My section", user: user)
sidebar_url_1 = Fabricate(:sidebar_url, name: "Sidebar Tags", value: "/tags")