billthefarmer / editor

Android simple text editor
https://billthefarmer.github.io/editor
GNU General Public License v3.0
474 stars 85 forks source link

Allow to close search by going "Back" #235

Open GfEW opened 1 month ago

GfEW commented 1 month ago

Your excellent solution to #225 works really well. Thank you!

Unfortunately, that substantial improvement makes one nasty remaining hurdle in Editor's keyboard navigability stand out all the more: You can enter search with Ctrl+F, search again with F3 or refine the search string just fine, but there's no way back out of search! (1)

How to reproduce:

  1. Edit some text in Editor with an external keyboard connected to your Android device.
  2. Press Ctrl+F to open and enter the search bar.
  3. Enter some search string, press Enter to search for it, and possibly F3 to search again, at will.
  4. Press Meta+Backspace to "navigate back". (Depending on your keyboard layout, you may have to press e. g. Win+Backspace or Option+Backspace instead, or press Back on your phone, or whichever navigation guesture or key combination triggers it.)

What does happen?

When in search, going Back leaves Editor alltogether.

What should happen instead?

When in search, going Back should leave and close the search bar (but not the entire app) and return the editing focus to the main text content.

(1)(Other than by closing and reopening Editor, or jumping through awkward Tab navigation hoops, that is.)

billthefarmer commented 1 month ago

Ctrl-Shift-F closes search. The Escape key acts as back.

GfEW commented 1 month ago

On Ctrl+Shift+F:

OIC, thanks for the pointer! - I do get the idea of "Shift" reversing the meaning of Ctrl+F that opens search.

Given that I hadn't noticed that particular Ctrl+Shift+F choice of yours in time when we were discussing more comprehensive shortcuts in #225, I should at least have taken the time to check the docs soon after. Sorry that I didn't.

Unfortunately, Ctrl+Shift+F is very uncommon for "cancel search". I, for one, didn't even think of testing it in all those months of "working around" this issue (before finally reporting it), but instead kept tediously closing and reopening files "in order to get out of search", again and again.

One of Editor's most outstanding qualities is certainly its powerful simplicity. Editor goes extremely light on the technical, as well as on the human brain side of resources. And it's somewhat against that grain if keyboard users have to consult the docs to learn that in Editor, a common, basic task like "close the search widget" is not designed to be done by the common "Back" navigation that intuitively works in the vast majority of searchable Android apps out of the box, but only by a very special shortcut they've never used before for that basic task.

I'm far from advocating a "no docs" solution - Editor provides advanced features that could hardly be made simpler than they already are. However, to minimize needless learning overhead, it's probably best to keep shortcuts for common actions as close to the standard as possible.

Is there any chance you'd reconsider and make "Back" close any search widget first, just like it closes the menu or e. g. the "Save to ..." dialog? - So the app will get closed by "Back" only if no search, menu or other dialog is active?

As far as I know, that's what "Back" should be doing, and actually does in virtually every app that provides a keyboard accessible search widget.

p. s. I suspect this closing effect of "Back" on the search widget is provided by the Android system in a way that doesn't need to be hard coded in every app that uses it. (Please forgive my vague language, I'm not an android developer.) Maybe https://chromeos.dev/en/android/input-compatibility#shortcuts gives any clues?

GfEW commented 1 month ago

Re: Escape

Note on how to input "Back":

Although I've sporadically encountered suggestions to get Back by pressing Escape on the keyboard, I've rarely seen it working anywhere on Android. (Termux is the one prominent app exception fully utilizing the Escape key, but it doesn't act as "Back" there, either.)

Search+Backspace, on the contrary, works consistently for me on all Android devices. (Actually, it's Meta+Backspace on my keyboard, as Android's "Search" appears to be mapped by "Meta"|"Option"|"Win" on Linux|Apple|Windows layouts, resp.)

According to Keyboard shortcut helper that opens by Search+/, the standard Back shortcut is indeed Search+Backspace. Apparently, it's only accompanied by Search+Left and Search+~ from A14 upwards, whilst Escape isn't listed there.

If my very limited understanding of the inner workings of Android shortcuts is correct, Search+Backspace is equivalent at the system level to tapping the Back button (if present) or performing the Back gesture (if configured), and has been so for over a decade. In my experience, all three work reliably throughout Android.