CTRL + F opens browser's finder tool rather then codemirror's

Hi, I am using the basic-setup module for my codemirror6 editor, so I am using searchKeymap from @codemirror/search, but often when I press Ctrl + F in my editor it opens the browser’s finder tool rather then codemirror’s (this happens somehow randomly, not all the times). How can I solve this? Is there a way to prioritize codemirror’s finder panel over the browser’s one? Or maybe I should add a button for codemirror’s finder?
I know I could maybe change the shortcut from Mod + F to something else, but I would prefer some better solution.
Thanks in advance.

1 Like

Ctrl-F should, with the search keymap enabled, always focus CodeMirror’s search panel and have preventDefault called on the key event, preventing the native search behavior. So I’m not sure what’s going on here. Do you have any further observations about when this happens? Does it happen in different browsers?

What I’ve found is that your cursor focus has to actually be in the CodeMirror text area. If it’s somewhere else on the page, Ctrl+F opens browser find, rather than CodeMirror find. I think this is the expected behavior, and I actually think it’s advantageous that way. You wouldn’t want it to open CodeMirror find if you want to search for something elsewhere on the page…

Really can’t tell why this happens… it usually happens when I’ve had the page with the editor opened for long time, it begins to change behavior from opening codemirror’s search panel to opening the browser’s one. Sometimes it gets back to normal behavior after waiting some minutes, other times I need to open a different browser (I experienced this problem with Chrome and Edge), or even restart the complete system

This happens even if you click in the CodeMirror text area before Ctrl+F? In my app I know this behavior exists, and I know that if Ctrl+F opens browser find, I just click in the CodeMirror text area and Ctrl+F again and it correctly opens CodeMirror find.