If you perform a System preferences search for a common word such as "type" or "log", you then lose the ability to expand or collapse the sections with names that appear more than once in the results page. All sections except the first one in each group of duplicates are affected by this. When you click on the 2nd, 3rd, etc. occurence of a section, the expand/collapse arrow does change, but in reality only the section that appears first in the page is actually toggled. I have created an animated GIF that shows this in action: https://imgur.com/a/NSslIcV This affects Koha 20.11.00 or later; `git bisect` tells me that the relevant commit is 9d890c7636ef1d6ec0a1de2161906fd9f4375e97 from Bug 23410. To reproduce: Perform a System preferences search for a common word such as "type" or "log". In the results page, the "Policy" section will appear more than once. Now try to expand/collapse any "Policy" section but the first one. It won't work, only the first "Policy" section is toggled.
This is happening because the page does not have unique ids for the <h3> elements. To see for yourself, perform the steps to reproduce, then open your web browser's Developer Tools (F12 key). Now copy/paste the following code [*] in the JavaScript console and press <ENTER>: ids = Array.from(document.querySelectorAll('h3[id]')) .map(v => v.id) .reduce((acc, v) => { acc[v] = (acc[v] || 0) + 1; return acc }, {}); dupes = Object.entries(ids) .filter(([key, value]) => value > 1); console.table(dupes); You should get a table in the console window similar to the one below: +---------+--------------+---+ | (index) | 0 | 1 | +---------+--------------+---+ | 0 | 'Features' | 3 | | 1 | 'Policy' | 2 | | 2 | 'Appearance' | 2 | +---------+--------------+---+ The table lists the <h3> ids that occur more than once in the DOM. The 2nd column is the actual id value and the last column is the number of occurences. Notice that the "Features" id occurs 3 times, while "Policy" and "Appearance" occur 2 times each. [*] Code adapted from https://stackoverflow.com/a/70373818
Created attachment 146440 [details] [review] Bug 32926: Assign unique ids to <h3> elements If you perform a System preferences search for a common word such as "type", you lose the ability to expand or collapse some sections. In particular, you cannot expand/collapse the sections with names that appear more than once in the results page. All sections except the first one in each group of duplicates are affected by this. See https://imgur.com/a/NSslIcV for a demo. This patch fixes that by prepending the <h3> ids with the top-level System preference section name to make them unique. Test plan: 1) Perform a System preferences search for a common word such as "type" or "log". In the results page, the "Policy" section will appear more than once. Now try to expand/collapse any "Policy" section but the first one. It won't work, only the first "Policy" section is toggled. 2) Apply this patch and refresh the page. 3) This time you should be able to expand or collapse all of the available system preference sections.
Created attachment 146441 [details] [review] Bug 32926: Add Selenium tests This adds a new Selenium test to automatically test the correct behaviour when expanding/collapsing System preferences sections after a System preferences search. Test plan: 1) Apply the other patch from this bug report, then run the new Selenium unit test which should pass without failures: prove -v t/db_dependent/selenium/system_preferences_search.t
Created attachment 146448 [details] [review] Bug 32926: Add Selenium tests This adds a new Selenium test to automatically test the correct behaviour when expanding/collapsing System preferences sections after a System preferences search. Test plan: 1) Apply the other patch from this bug report, then run the new Selenium unit test which should pass without failures: prove -v t/db_dependent/selenium/system_preferences_search.t
Apologies, I somehow messed up the file permissions on the Selenium unit test file just before committing (644 instead of the correct 755). This has now been fixed and I've obsoleted my previous patch.
I've tested, works well. But this breaks the links "View all xxx preferences", which link to an id (ie #Policy).
(In reply to Fridolin Somers from comment #6) > I've tested, works well. Thanks for the feedback, Fridolin. > But this breaks the links "View all xxx preferences", > which link to an id (ie #Policy). Ah, well spotted! I will provide a follow-up patch.
Created attachment 146852 [details] [review] Bug 32926: Assign unique ids to <h3> elements If you perform a System preferences search for a common word such as "type", you lose the ability to expand or collapse some sections. In particular, you cannot expand/collapse the sections with names that appear more than once in the results page. All sections except the first one in each group of duplicates are affected by this. See https://imgur.com/a/NSslIcV for a demo. This patch fixes that by prepending the <h3> ids with the top-level System preference section name to make them unique. Test plan: 1) Perform a System preferences search for a common word such as "type" or "log". In the results page, the "Policy" section will appear more than once. Now try to expand/collapse any "Policy" section but the first one. It won't work, only the first "Policy" section is toggled. 2) Apply this patch and refresh the page. 3) This time you should be able to expand or collapse all of the available system preference sections. 4) Clicking on the "View all xxx preferences" links on the right hand side should take you to the correct System preferences tab *and* automatically scroll the appropriate section into view at the top of the page.
(In reply to Andreas Roussos from comment #7) > Ah, well spotted! I will provide a follow-up patch. Actually, since this hasn't been signed off yet, I amended my previous patch and added an extra item to the test plan to cater for the issue that Fridolin has spotted.
Created attachment 146973 [details] [review] Bug 32926: Add Selenium tests This adds a new Selenium test to automatically test the correct behaviour when expanding/collapsing System preferences sections after a System preferences search. Test plan: 1) Apply the other patch from this bug report, then run the new Selenium unit test which should pass without failures: prove -v t/db_dependent/selenium/system_preferences_search.t Signed-off-by: Fridolin <fridolin.somers@biblibre.com>
Created attachment 146974 [details] [review] Bug 32926: Assign unique ids to <h3> elements If you perform a System preferences search for a common word such as "type", you lose the ability to expand or collapse some sections. In particular, you cannot expand/collapse the sections with names that appear more than once in the results page. All sections except the first one in each group of duplicates are affected by this. See https://imgur.com/a/NSslIcV for a demo. This patch fixes that by prepending the <h3> ids with the top-level System preference section name to make them unique. Test plan: 1) Perform a System preferences search for a common word such as "type" or "log". In the results page, the "Policy" section will appear more than once. Now try to expand/collapse any "Policy" section but the first one. It won't work, only the first "Policy" section is toggled. 2) Apply this patch and refresh the page. 3) This time you should be able to expand or collapse all of the available system preference sections. 4) Clicking on the "View all xxx preferences" links on the right hand side should take you to the correct System preferences tab *and* automatically scroll the appropriate section into view at the top of the page. Signed-off-by: Fridolin <fridolin.somers@biblibre.com>
Created attachment 147197 [details] [review] Bug 32926: Add Selenium tests This adds a new Selenium test to automatically test the correct behaviour when expanding/collapsing System preferences sections after a System preferences search. Test plan: 1) Apply the other patch from this bug report, then run the new Selenium unit test which should pass without failures: prove -v t/db_dependent/selenium/system_preferences_search.t Signed-off-by: Fridolin <fridolin.somers@biblibre.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Created attachment 147198 [details] [review] Bug 32926: Assign unique ids to <h3> elements If you perform a System preferences search for a common word such as "type", you lose the ability to expand or collapse some sections. In particular, you cannot expand/collapse the sections with names that appear more than once in the results page. All sections except the first one in each group of duplicates are affected by this. See https://imgur.com/a/NSslIcV for a demo. This patch fixes that by prepending the <h3> ids with the top-level System preference section name to make them unique. Test plan: 1) Perform a System preferences search for a common word such as "type" or "log". In the results page, the "Policy" section will appear more than once. Now try to expand/collapse any "Policy" section but the first one. It won't work, only the first "Policy" section is toggled. 2) Apply this patch and refresh the page. 3) This time you should be able to expand or collapse all of the available system preference sections. 4) Clicking on the "View all xxx preferences" links on the right hand side should take you to the correct System preferences tab *and* automatically scroll the appropriate section into view at the top of the page. Signed-off-by: Fridolin <fridolin.somers@biblibre.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Created attachment 147199 [details] [review] Bug 32926: Fix selenium tests We should not rely on existing data, and we should remove data at the end. Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Pushed to master for 23.05. Nice work everyone, thanks!
Nice work everyone! Pushed to stable for 22.11.x
Backported to 22.05.x for upcoming 22.05.11
applied to 21.11 for 21.11.19
Not backported to 21.05.x
Created attachment 150739 [details] [review] Bug 32926: Restore scroll to sub-tab Test plan: Go to sys prefs, click 'Enhanced Content' Click 'OverDrive', notice it doesnt scroll there Apply this patch: Do the same test plan, but notice it does scroll there, like before
Made patch obsolete, opened bug 33687 instead.