yari icon indicating copy to clipboard operation
yari copied to clipboard

Search box overrides Home and End key

Open Nickwiz opened this issue 2 years ago • 1 comments

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event

What specific section or headline is this issue about?

Search box

What information was incorrect, unhelpful, or incomplete?

The search box has bound Home and End to jump to start / end of suggestion list.

This interfere if one want to jump in the text one is writing. I.e.

some text| here
         |
         +---- cursor here

By pressing:

  • Home: Cursor is not moved to start but one navigates the start of suggestion list.
  • Shift + Home: One do not select all text before cursor, but navigates to start of suggestion list.

Further if there is one or no suggestions it appears as if the Home and End keys are not working as nothing happens.

Believe one should do a check for Shift and Ctrl when Home and End is pressed.

  • Home: Start of suggestion list
  • End: End of suggestion list
  • Ctrl + Home: Jump to start of input (Default behavior)
  • Ctrl + End: Jump to end of input (Default behavior)
  • (Ctrl +)1 Shift + Home: Select text from cursor to start (Default behavior)
  • (Ctrl +)1 Shift + End: Select text from cursor to end (Default behavior)

1: Ctrl not needed as it is not a textarea but behavior is the same with / without

In other words, "simply" not navigate the suggestion list if either modifier is pressed and let the browser do it's default action.

One could of course also turn it around and say:

  • Ctrl + Home: Jump to start of suggestion list
  • Ctrl + End: Jump to end of suggestion list

And leave Home and End as their defaults - but think this would perhaps be more confusing.

What did you expect to see?

When pressing Shift + Home for the text to be selected.

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

Not sure if this is the correct place to submit this bug / suggestion, but closest I found.

Addition

(Unable to add Comment in thread without also Closing the ticket - so added this section as an edit).

Forgot to change: (Sorry about that)

If suggestion list is empty: leave all key-presses as default.

I.e. Home, End keys move around in text of input field and and not suggestions.

Believe that would be more end-user friendly as it does not seem like disabled keys.

So, should have been:

  • Home: Start of suggestion list if any, else start of input field
  • End: End of suggestion list, else start of input field

Nickwiz avatar Jun 05 '22 04:06 Nickwiz

Could have a look at it, but no idea where in the code-base to start reading.

Any discussion on what would be more intuitive would also be nice.

In general, after thinking about it, I believe

  • Pressing Home or End should go to start / end of text.

This is the common behavior in 99.99% of all editors, text inputs etc.

  • Pressing Ctrl+Home -> start of suggestions.
  • Pressing Ctrl+End -> end of suggestions.

That would be logical if comparing to a multi-line input on about the same percentage of inputs.

The Esc key also clears the input instead of only closing the suggestion drop-down. Hence one can not escape and do Home / End either + if one do what ever one had typed is gone.

Nickwiz avatar Jul 01 '22 14:07 Nickwiz

Hi @Nickwiz, thank you for taking the time to open this issue. 👋

Please note that we're using Downshift.js and their Combobox implementation for the search suggestions, and we haven't customized their default event handlers, nor do we plan to do so.

However, you should be able to use Ctrl+LeftArrow and Ctrl+RightArrow to go to the start / end of the input value. 😉

caugner avatar Sep 12 '22 21:09 caugner