framework icon indicating copy to clipboard operation
framework copied to clipboard

save search query, and restore on cmd-K

Open Fil opened this issue 1 year ago • 5 comments

as I'm working on a project with ~300 pages, I find that not having this feature is very annoying, since when I'm working on "calendar" (say…), I have to re-type the same search query again and again (I'll test a bit with the feature on, I hope that it's not annoying in a different way :-) )

  • [x] Almost perfect, but I need to normalize paths so that e.g. /maplibre-gl#12/47.27574/11.39085/0/52 matches /maplibre-gl

closes #889

https://github.com/observablehq/framework/assets/7001/c1e75d2e-746f-4ce8-8a78-dbd1639d802c

Fil avatar Feb 22 '24 21:02 Fil

It can be live-tested on the "pangea" project.

Fil avatar Feb 27 '24 21:02 Fil

What if…

  • We keep a recent history of searches (captured either on clearing the search field by clicking the x or hitting Esc, or by navigating to a result)
  • When the search box is empty, the up arrow would restore the most-recent search result and select all the text of the search query
  • When the search query is selected in its entirety (and non-empty), the up and down arrow would navigate the search history, changing the query (instead of navigating within the search results)
  • When the search query is selected in its entirety, hitting Enter would unselect the text and put the caret to the end of the search query, allowing you to either edit the query or hit Enter again to select the top result

I think it’s a good idea to have a way to restore previous queries. I just want it to be accessible through clicking rather than only Command-K, and I want it to be a bit more of a deliberate action than changing the normal behavior.

mbostock avatar Mar 02 '24 13:03 mbostock

The current PR is not just restoring the previous query (only one in this PR), it's also positioning the cursor to the current page (if it's one of the search results), so you can iterate through the list with one arrowDown. I'm not sure if what you suggest would be as convenient for this use case, but the only way to know is to try. (And I'm not sure if this use case is that important… it's just what I've been optimizing for as I was working on porting dozens of notebooks.)

In any case I fully agree that it should work on focus, rather than only on cmd-K. (DONE)

Fil avatar Mar 02 '24 14:03 Fil

This PR works as before, but on focus; it only remembers/restores the previous query, but requires a small number of actions from the user. I'm exploring the alternative UI in #1044.

Fil avatar Mar 12 '24 13:03 Fil

rebased

Fil avatar Apr 29 '24 17:04 Fil