FIX: update bookmark UI when using keyboard shortcut (#37639)

When pressing B then Enter to bookmark a topic, the bookmark icon next
to the topic title and the topic footer bookmark button did not update
until page reload.

The keyboard shortcut path opens the BookmarkModal directly via the
topic controller, bypassing the TopicBookmarkManager that the footer's
BookmarkMenu component relies on. The afterSave callback correctly sets
`topic.bookmarked = true`, but the `topicBookmarkManager` computed
property only depended on `"topic"` (the object identity), so it never
recreated the manager to pick up the new bookmark state.

Changed the dependent key to `"topic.bookmarked"` so the manager is
recreated whenever the bookmarked property changes, regardless of which
code path triggered it.
This commit is contained in:
Régis Hanol
2026-02-10 11:49:53 +01:00
committed by GitHub
parent a851595fc7
commit 1e9524315e
3 changed files with 24 additions and 1 deletions
@@ -66,7 +66,7 @@ export default class TopicFooterButtons extends Component {
);
}
@computed("topic")
@computed("topic.bookmarked")
get topicBookmarkManager() {
return new TopicBookmarkManager(getOwner(this), this.topic);
}
+15
View File
@@ -119,6 +119,21 @@ describe "Bookmarking posts and topics", type: :system do
)
end
it "updates the topic status and footer button when using the keyboard shortcut" do
topic_page.visit_topic(topic)
expect(topic_page).to have_no_topic_status_bookmark
expect(topic_page).to have_no_bookmarks(topic)
send_keys("b")
expect(bookmark_modal).to be_open
send_keys(:enter)
expect(bookmark_modal).to be_closed
expect(topic_page).to have_topic_status_bookmark
expect(topic_page).to have_topic_bookmarked(topic)
expect(Bookmark.exists?(bookmarkable: topic, user: current_user)).to eq(true)
end
it "bookmark button is topic specific" do
topic_page.visit_topic(topic_2)
topic_page.click_topic_bookmark_button
+8
View File
@@ -224,6 +224,14 @@ module PageObjects
within_topic_footer_buttons { has_no_css?(".bookmark-menu-trigger.bookmarked") }
end
def has_topic_status_bookmark?
has_css?("#topic-title .topic-status.--bookmarked")
end
def has_no_topic_status_bookmark?
has_no_css?("#topic-title .topic-status.--bookmarked")
end
def click_reply_button
within_topic_footer_buttons { find(".create").click }
has_expanded_composer?