I am trying to implement “Find” functionality (Find, Find Next) in my app using webContents.findInPage(). When the user invokes “Find” command, I present a search box, where the user can type what to search for. The search box is implemented as an input element (of my webapp). In the “keyup” event I call webContents.findInPage().
I have run into a couple of issues with this approach:
The input element itself seems to included in the webContents.findInPage() search, which interferes with the subsequent “find next” function. I did not find any way to mark the input element to be excluded from findInPage() search.
Every time findInPage() is called, it steals focus from the input element (so that the user must click back into the input). Hacks like regaining focus in “blur” event or via setTimeout() are not reliable.
Any idea how to work around it?