FIX: Improve topic/header integration when navigating away (#28040)

- Ensure main title is set as 'not visible' when removed from DOM

- `deactivate` -> `willTransition` to ensure proper behavior when navigating between multiple topics

Followup to bdec564d1417c51ef6958784fdd6375fd05da4fc
This commit is contained in:
David Taylor
2024-07-23 14:57:15 +01:00
committed by GitHub
parent 5b693c61af
commit c333e9d6e6
4 changed files with 38 additions and 21 deletions

View File

@ -262,7 +262,7 @@ RSpec.describe "Glimmer Header", type: :system do
describe "mobile topic-info" do
fab!(:topic)
fab!(:posts) { Fabricate.times(5, :post, topic: topic) }
fab!(:posts) { Fabricate.times(21, :post, topic: topic) }
it "only shows when scrolled down", mobile: true do
visit "/t/#{topic.slug}/#{topic.id}"
@ -286,5 +286,19 @@ RSpec.describe "Glimmer Header", type: :system do
expect(page).not_to have_css("header.d-header .auth-buttons .login-button") # No header buttons
expect(page).to have_css("header.d-header .title-wrapper .topic-link") # Title is shown in header
end
it "shows when jumping from OP to much later post", mobile: true do
visit "/t/#{topic.slug}/#{topic.id}"
expect(page).to have_css("#topic-title") # Main topic title
expect(page).to have_css("header.d-header .auth-buttons .login-button") # header buttons visible when no topic-info in header
page.execute_script("Discourse.visit('/t/#{topic.slug}/#{topic.id}/21');")
expect(page).to have_css("#post_21")
expect(page).not_to have_css("header.d-header .auth-buttons .login-button") # No header buttons
expect(page).to have_css("header.d-header .title-wrapper .topic-link") # Title is shown in header
end
end
end