Enable text search (Ctrl+F) in Desktop #5877

Open
opened 2021-04-13 11:05:20 +02:00 by infinite-persistence · 8 comments
infinite-persistence commented 2021-04-13 11:05:20 +02:00 (Migrated from github.com)

Often while searching, I want to go back to an entry way up in the search list that I still remember it's title partially. This is easy to do on the web browser via Find (or Ctrl+F), but not so on Desktop.

It would also be helpful for searching through long comments.

Often while searching, I want to go back to an entry way up in the search list that I still remember it's title partially. This is easy to do on the web browser via Find (or Ctrl+F), but not so on Desktop. It would also be helpful for searching through long comments.
tzarebczan commented 2021-04-19 21:27:38 +02:00 (Migrated from github.com)

This should be fixed by https://github.com/lbryio/lbry-desktop/pull/5874 right?

This should be fixed by https://github.com/lbryio/lbry-desktop/pull/5874 right?
infinite-persistence commented 2021-04-20 02:41:36 +02:00 (Migrated from github.com)

Differerent -- this one adds text search to electron.

Differerent -- this one adds text search to electron.
tzarebczan commented 2021-04-20 05:46:59 +02:00 (Migrated from github.com)

Ah roger!

Ah roger!
mayeaux commented 2021-05-12 21:33:59 +02:00 (Migrated from github.com)

I looked into this, and it's possible but possibly not very trivial to implement.

Possible to do find within a page? Cmd/Ctrl+F? | Electron Issue
https://github.com/electron/electron/issues/2037

Electron does offer this API for finding content:
https://www.electronjs.org/docs/api/web-contents#contentsfindinpagetext-options

And then an event listener that you could hook into as well:
https://www.electronjs.org/docs/api/web-contents#event-found-in-page

So presumably you could build a small GUI that could interact with this API. In fact, someone has built a module for achieving this ctrl + f search effect, but it's not clear that it will work in later versions of Electron (I opened a ticket asking about it: https://github.com/TheoXiong/electron-find/issues/18)

https://github.com/TheoXiong/electron-find

So best case scenario, that module would work on Electron v12 because it seems to be coded quite well, and then you could just plug and play it. Worst case you'd have to build something by hand but it should be possible if not a little annoying (and at least you have this guy's working implementation to go off of).

I agree it's pretty annoying and jarring to not have CTRL + F search functionality, especially given that it's available on web browsers. Depends on dev time and perceived impact on users if this is considered worth prioritizing, but the good news is that Electron has an API that at least does make it possible.

I looked into this, and it's possible but possibly not very trivial to implement. Possible to do find within a page? Cmd/Ctrl+F? | Electron Issue https://github.com/electron/electron/issues/2037 Electron does offer this API for finding content: https://www.electronjs.org/docs/api/web-contents#contentsfindinpagetext-options And then an event listener that you could hook into as well: https://www.electronjs.org/docs/api/web-contents#event-found-in-page So presumably you could build a small GUI that could interact with this API. In fact, someone has built a module for achieving this ctrl + f search effect, but it's not clear that it will work in later versions of Electron (I opened a ticket asking about it: https://github.com/TheoXiong/electron-find/issues/18) https://github.com/TheoXiong/electron-find So best case scenario, that module would work on Electron v12 because it seems to be coded quite well, and then you could just plug and play it. Worst case you'd have to build something by hand but it should be possible if not a little annoying (and at least you have this guy's working implementation to go off of). I agree it's pretty annoying and jarring to not have CTRL + F search functionality, especially given that it's available on web browsers. Depends on dev time and perceived impact on users if this is considered worth prioritizing, but the good news is that Electron has an API that at least does make it possible.
wilkerlucio commented 2021-05-14 21:48:34 +02:00 (Migrated from github.com)

I'm going through the process now, and I can tell it's painful.

I couldn't figure how to make electron-find work with Electron 12, pulling the polyfill for remote on Electron didn't do the trick.

As I'm trying to implement manually (using the findInPage helper), there are pain points, because it's a UI event that needs to go in the background to trigger something back again. I got that part working, but every time the find is fired, the input that's doing the search loses focus. I can make it refocus, but the UI feels kinda bad. Also, if you trigger findInPage multiple times it does cycle between the occurrences, but if I do the focus back thing, it loses track of it.

So I see electron-find and other solutions used to rely on <webview /> element to avoid this focus madness, but Electron warns to not use it. I didn't try yet, just wanna say it's a really painful process, would be great if Electron provides something easy to use out of the box. It is great to have the flexibility with findInPage, but I believe most people just want a replication of what the browsers do, and Electron could provide that too.

I'm going through the process now, and I can tell it's painful. I couldn't figure how to make `electron-find` work with Electron 12, pulling the polyfill for `remote` on Electron didn't do the trick. As I'm trying to implement manually (using the `findInPage` helper), there are pain points, because it's a UI event that needs to go in the background to trigger something back again. I got that part working, but every time the find is fired, the input that's doing the search loses focus. I can make it refocus, but the UI feels kinda bad. Also, if you trigger `findInPage` multiple times it does cycle between the occurrences, but if I do the focus back thing, it loses track of it. So I see `electron-find` and other solutions used to rely on `<webview />` element to avoid this focus madness, but [Electron warns to not use it](https://www.electronjs.org/docs/api/webview-tag#warning). I didn't try yet, just wanna say it's a really painful process, would be great if Electron provides something easy to use out of the box. It is great to have the flexibility with `findInPage`, but I believe most people just want a replication of what the browsers do, and Electron could provide that too.
tzarebczan commented 2021-05-14 22:31:57 +02:00 (Migrated from github.com)

I just realized this was not linked to the PR that was in process, sounds like the author is taking another shot: https://github.com/lbryio/lbry-desktop/pull/5938

I just realized this was not linked to the PR that was in process, sounds like the author is taking another shot: https://github.com/lbryio/lbry-desktop/pull/5938
TomasGonzalez commented 2021-05-15 01:52:18 +02:00 (Migrated from github.com)

I'm going through the process now, and I can tell it's painful.

I couldn't figure how to make electron-find work with Electron 12, pulling the polyfill for remote on Electron didn't do the trick.

As I'm trying to implement manually (using the findInPage helper), there are pain points, because it's a UI event that needs to go in the background to trigger something back again. I got that part working, but every time the find is fired, the input that's doing the search loses focus. I can make it refocus, but the UI feels kinda bad. Also, if you trigger findInPage multiple times it does cycle between the occurrences, but if I do the focus back thing, it loses track of it.

So I see electron-find and other solutions used to rely on <webview /> element to avoid this focus madness, but Electron warns to not use it. I didn't try yet, just wanna say it's a really painful process, would be great if Electron provides something easy to use out of the box. It is great to have the flexibility with findInPage, but I believe most people just want a replication of what the browsers do, and Electron could provide that too.

I already have a PR opened #5938 I went around the focus thing by searching when enter is pressed, this doesn't match the browser behavior but at least makes searching possible.
I'm gonna give it a try with the electron-find later, and possibly with the webview approach if I also have no success.

> I'm going through the process now, and I can tell it's painful. > > I couldn't figure how to make `electron-find` work with Electron 12, pulling the polyfill for `remote` on Electron didn't do the trick. > > As I'm trying to implement manually (using the `findInPage` helper), there are pain points, because it's a UI event that needs to go in the background to trigger something back again. I got that part working, but every time the find is fired, the input that's doing the search loses focus. I can make it refocus, but the UI feels kinda bad. Also, if you trigger `findInPage` multiple times it does cycle between the occurrences, but if I do the focus back thing, it loses track of it. > > So I see `electron-find` and other solutions used to rely on `<webview />` element to avoid this focus madness, but [Electron warns to not use it](https://www.electronjs.org/docs/api/webview-tag#warning). I didn't try yet, just wanna say it's a really painful process, would be great if Electron provides something easy to use out of the box. It is great to have the flexibility with `findInPage`, but I believe most people just want a replication of what the browsers do, and Electron could provide that too. I already have a PR opened #5938 I went around the focus thing by searching when enter is pressed, this doesn't match the browser behavior but at least makes searching possible. I'm gonna give it a try with the electron-find later, and possibly with the webview approach if I also have no success.
TomasGonzalez commented 2021-05-16 06:02:12 +02:00 (Migrated from github.com)

I'm going through the process now, and I can tell it's painful.

I couldn't figure how to make electron-find work with Electron 12, pulling the polyfill for remote on Electron didn't do the trick.

As I'm trying to implement manually (using the findInPage helper), there are pain points, because it's a UI event that needs to go in the background to trigger something back again. I got that part working, but every time the find is fired, the input that's doing the search loses focus. I can make it refocus, but the UI feels kinda bad. Also, if you trigger findInPage multiple times it does cycle between the occurrences, but if I do the focus back thing, it loses track of it.

So I see electron-find and other solutions used to rely on <webview /> element to avoid this focus madness, but Electron warns to not use it. I didn't try yet, just wanna say it's a really painful process, would be great if Electron provides something easy to use out of the box. It is great to have the flexibility with findInPage, but I believe most people just want a replication of what the browsers do, and Electron could provide that too.

Update:
webview method will keep unfocusing unless you also put the whole app into another separate webview, so I ditched this idea. Now I'm going to proceed and try to brute force search the DOM and compare the innerhtml of each element to the search input.

> I'm going through the process now, and I can tell it's painful. > > I couldn't figure how to make `electron-find` work with Electron 12, pulling the polyfill for `remote` on Electron didn't do the trick. > > As I'm trying to implement manually (using the `findInPage` helper), there are pain points, because it's a UI event that needs to go in the background to trigger something back again. I got that part working, but every time the find is fired, the input that's doing the search loses focus. I can make it refocus, but the UI feels kinda bad. Also, if you trigger `findInPage` multiple times it does cycle between the occurrences, but if I do the focus back thing, it loses track of it. > > So I see `electron-find` and other solutions used to rely on `<webview />` element to avoid this focus madness, but [Electron warns to not use it](https://www.electronjs.org/docs/api/webview-tag#warning). I didn't try yet, just wanna say it's a really painful process, would be great if Electron provides something easy to use out of the box. It is great to have the flexibility with `findInPage`, but I believe most people just want a replication of what the browsers do, and Electron could provide that too. Update: webview method will keep unfocusing unless you also put the whole app into another separate webview, so I ditched this idea. Now I'm going to proceed and try to brute force search the DOM and compare the innerhtml of each element to the search input.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: LBRYCommunity/lbry-desktop#5877
No description provided.