ad-freiburg / qlever-ui

A user interface for QLever
Apache License 2.0
19 stars 12 forks source link

Add keyword search to filter example queries #83

Open IoannisNezis opened 3 months ago

IoannisNezis commented 3 months ago

This PR adds a keyword-search to filter the example querys (by name).

before after
20240306_18h35m47s_grim 20240306_17h53m32s_grim

Each whitespace sperated word needs to appear in the result.

The search matches the keyword also infix 20240306_18h12m52s_grim

When no result matches the query, a message is displayed. 20240306_18h41m10s_grim

IoannisNezis commented 3 months ago

Maybe debouncing the search would be nice

IoannisNezis commented 3 months ago

I played around a bit with different highlighting options:

background underline
20240323_19h02m39s_grim 20240323_19h04m02s_grim

I personally prefer the underline option, any opinions?

hannahbast commented 3 months ago

@IoannisNezis This is awesome! It's live on https://qlever.cs.uni-freiburg.de for some time now and I use it for almost every example query. The underlining looks great. A minor suggestion for further improvement: When one clicks on the Example button, the focus should be in the search field so that one can start typing right away without first clicking into the search field

hannahbast commented 3 months ago

@IoannisNezis This looks great now.

Another small request, which occurred to me already when trying this out the first time and still occurs to me now every time I used the new feature:

When selecting a query using the "Example" button one has to:

  1. Press the Example button
  2. Start typing some word fragments (thanks to your latest change, a click in the search field is no longer necessary)
  3. Click on the desired query
  4. Execute the query

For Step 4, there is the Shortut Ctrl+Return, which I always use to execute a query (after you type the query, you can just continue typing in instead of having to switch to the mouse again just for a single click).

But with the workflow above, I have to click, type, click, click

It would be awesome if one could select the query with either TAB or arrow-up / arrow down and then select it via Return (and another Ctrl+Return would then execute it). Interestingly, when pressing TAB once, one already gets to "Add new example", and then Return takes you to the corresponding page. So maybe realizing this with TAB is relatively little additional work.

IoannisNezis commented 3 months ago

@hannahbast I actually already started working on this, initially this is a bit of a pain. I did not look into the tabindex direction yet, thanks for the idea.

At this point it might be worth mentioning that i am re-implementing parts of this library: https://select2.org/ which i initially choose not to use.

If there is a good reason not to use this library i would be really happy (sunken cost fallacy is kicking in really badly). One reason might be: being able to search for multiple keywords of one example.

IoannisNezis commented 2 months ago

I implemented the keyboard control. It should now be possible to search, select and execute an example query while only clicking once.

I decided against the tabulator option and implemented the selection with arrow keys.

Further improvements

I want to implement 2 further improvements:

Scroll

The list of possible examples is a bit long.
i want to make the list scrollable, instead of showing everything.

Exclusive Hover

Currently one can select a example with the mouse and the arrow keys.
I want to change this so that if one hovers an example only this example is highlighted. If the arrow key is used after a element is hovered with the mouse it should propagate from this element.

IoannisNezis commented 2 months ago

@hannahbast In the last 2 commits I implemented the formatting changes we discussed (typo, line-length, ...).

A few things:

  1. What is the procedure for closing threads in PR's? Should only the reviewer close them or can the assignee also close threads if its reasonable?

  2. In a previous comment i suggested two further improvements. I would like to address them in separate PR's to keep this one at a manageable size.