Users discuss enhancing Discourse’s keyboard navigation: pressing Ctrl+F twice should close the Discourse search overlay and activate the browser’s native find-in-page function. gerhard initiates the thread, noting that while the first Ctrl+F opens Discourse’s search, the second should switch to the browser’s search — but currently doesn’t close the overlay. cpradio acknowledges the complexity due to how Mousetrap (Discourse’s keybinding library) handles input fields. gerhard suggests a fix by adding class="mousetrap" to the input field. tgxworld submits a PR, but gerhard clarifies the desired behavior: second Ctrl+F must close Discourse’s overlay and focus the browser’s search. tgxworld finds this behavior potentially confusing, but gerhard insists it’s intentional and useful for long topics. tgxworld and gerhard debate whether the current behavior is a bug or feature. gerhard later submits a working PR, which tgxworld confirms improves the experience. A regression is noted tgxworld, and gerhard traces it to a recent fix. cpradio jokes about stability. tgxworld suggests adding a test to ensure the behavior works on long topics. FichteFoll notes this behavior is documented elsewhere and helpful for keyboard users. codinghorror adds that topic length may affect behavior. The thread reflects iterative collaboration to refine a small but impactful UX improvement.
I sometimes want to use the browser search window within topics since the Discourse search function jumps only to posts and not the exact position of the search term. Pressing Ctrl+F works quite well.
However, the Discourse search window doesn’t close automatically when I use the browser’s search function. The first few search results therefore are often within the search window. That’s quite annoying.
Hmm… That may be easier said than done. As by default the keyboard keypress framework that Discourse uses, doesn’t capture keypresses that are made in input boxes (which is why pressing it twice works).
So there is nothing capturing the second pressing of it. And if we did, you’d have us capturing it instead of the browser responding to it… So its a bit of catch-22 here.
Thanks for your PR. Unfortunately it doesn’t work the way I imagined, but I guess that’s because I didn’t exactly describe the behavior I wanted. I’ll clarify it:
Expected behavior: When I press Ctrl+F the second time, the Discourse search window should close automatically and the browser’s search window should be visible and have focus.
Current behavior without the PR: When I press Ctrl+F the second time, the Discourse search window stays open and the browser’s search window is visible and has focus.
Behavior with the PR: When I press Ctrl+F the second time, the Discourse search window closes, but there is now browser search window.
@gerhard thanks for clarifying I do find the proposed behavior to be confusing for users as I’m not sure how we can clearly bring across the behavior to users that pressing Ctrl + f twice will first bring up Discourse search and then the browser’s search.
But that is exactly what is happening if you press Ctrl+F in a topic with lots of posts. Try it out yourself by pressing it inside a topic with more than 20 posts.
And it is good that this is happening since I want to be able to search using my browser. It has a better search experience. My problem right now is that the Discourse search window stays visible and I get lots of search results from the browser that are within Discourse’s search results. See my screenshot in the first post.
I do understand what you mean and I believe the browser’s search appearing is a bug since Discourse has made the decision to hijack the search on the first ctrl+f.