Bug 35498

Summary: SQL auto-complete should not prevent use of tab for spacing
Product: Koha Reporter: Andrew Fuerste-Henry <andrewfh>
Component: ReportsAssignee: Matt Blenkinsop <matt.blenkinsop>
Status: Pushed to oldstable --- QA Contact: Lucas Gass <lucas>
Severity: normal    
Priority: P5 - low CC: dcook, fridolin.somers, kebliss, lucas, matt.blenkinsop
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.05.00,23.11.02,23.05.08
Bug Depends on: 32613    
Bug Blocks:    
Attachments: Bug 35498: Allow tab to indent lines and trigger autocomplete
Bug 35498: Allow tab to indent lines and trigger autocomplete
Bug 35498: Allow tab to indent lines and trigger autocomplete
Bug 35498: Allow tab to indent lines and trigger autocomplete

Description Andrew Fuerste-Henry 2023-12-05 20:11:40 UTC
With the new auto-complete feature for SQL, the tab key *always* opens the auto-complete suggestions popup, even when the cursor is at the start of a new line or immediately after a whitespace. This makes tab unusable for spacing/formatting, which is difficult functionality to use.

In a code editor, I expect tab to auto-complete if I've started a word/string, but to insert a whitespace if I'm at the start of a line or otherwise between words.
Comment 1 Katrin Fischer 2023-12-05 20:56:41 UTC
Hm, I don't think the tab ever worked there for adding whitespace/tab, so maybe not a regression and tab for auto-complete seems common?
Comment 2 Andrew Fuerste-Henry 2023-12-05 21:25:28 UTC
I'm deeply accustomed to tab-indenting new lines when writing reports in Koha and am certain this is a change.
Comment 3 Katrin Fischer 2023-12-05 21:28:36 UTC
(In reply to Andrew Fuerste-Henry from comment #2)
> I'm deeply accustomed to tab-indenting new lines when writing reports in
> Koha and am certain this is a change.

Hm OK, I might have never tried, but seem to remember getting annoyed by it not working in the system preferences (*UserJS etc). Maybe some changes happened over time. 

Usually a normal HTML input field doesn't allow it (like here in bugzilla), as the tab is used in form fields to jump to the next field.
Comment 4 David Cook 2023-12-05 22:29:29 UTC
I can confirm Andrew's report, and I agree that it is frustrating.
Comment 5 David Cook 2023-12-05 22:34:57 UTC
I notice that the "tab" is in a list of exclusions in guided_reports_start.tt at https://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=32613&attachment=147715

However, it looks like it is triggering the autocomplete anyway.

I imagine PTFS-Europe as the folk who introduced the change might have an idea on how to fix it.
Comment 6 Matt Blenkinsop 2023-12-06 15:17:44 UTC
Created attachment 159622 [details] [review]
Bug 35498: Allow tab to indent lines and trigger autocomplete

This patch allows the tab key to indent lines as well as trigger autocomplete.

Test plan:
1) Apply patch, navigate to reports and create a new SQL report
2) Click in the text editor and press tab, it should indent and then trigger the autocomplete options
3) Type something to select from the autocomplete box and press tab - it should autocomplete that option
4) Type any word and then press space. Now press tab and it should indent again
Comment 7 Matt Blenkinsop 2023-12-06 15:36:13 UTC
Created attachment 159623 [details] [review]
Bug 35498: Allow tab to indent lines and trigger autocomplete

This patch allows the tab key to indent lines as well as trigger autocomplete.

Test plan:
1) Apply patch, navigate to reports and create a new SQL report
2) Click in the text editor and press tab, it should indent and then trigger the autocomplete options
3) Type something to select from the autocomplete box and press tab - it should autocomplete that option
4) Type any word and then press space. Now press tab and it should indent again
Comment 8 ByWater Sandboxes 2023-12-06 16:12:43 UTC
Created attachment 159625 [details] [review]
Bug 35498: Allow tab to indent lines and trigger autocomplete

This patch allows the tab key to indent lines as well as trigger autocomplete.

Test plan:
1) Apply patch, navigate to reports and create a new SQL report
2) Click in the text editor and press tab, it should indent and then trigger the autocomplete options
3) Type something to select from the autocomplete box and press tab - it should autocomplete that option
4) Type any word and then press space. Now press tab and it should indent again

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Comment 9 Lucas Gass 2023-12-06 16:20:19 UTC
Created attachment 159626 [details] [review]
Bug 35498: Allow tab to indent lines and trigger autocomplete

This patch allows the tab key to indent lines as well as trigger autocomplete.

Test plan:
1) Apply patch, navigate to reports and create a new SQL report
2) Click in the text editor and press tab, it should indent and then trigger the autocomplete options
3) Type something to select from the autocomplete box and press tab - it should autocomplete that option
4) Type any word and then press space. Now press tab and it should indent again

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 10 Lucas Gass 2023-12-06 16:20:53 UTC
Thanks for the quick fix, Matt. Works great, passing QA.
Comment 11 David Cook 2023-12-06 22:52:12 UTC
You're a legend, Matt. Thanks for hopping on this one!
Comment 12 Katrin Fischer 2023-12-13 10:35:28 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 13 Fridolin Somers 2024-01-03 13:16:09 UTC
Pushed to 23.11.x for 23.11.02
Comment 14 Lucas Gass 2024-01-04 18:13:19 UTC
Backported to 23.05.x for upcoming 23.05.08