Bug 20501 - Unhighlight in search results when the search terms contain the same word twice removes the word
Summary: Unhighlight in search results when the search terms contain the same word twi...
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Staff interface (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Phil Ringnalda
QA Contact: Josef Moravec
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-29 21:20 UTC by Phil Ringnalda
Modified: 2021-11-26 10:54 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.05.00, 19.11.06, 19.05.11
Circulation function:


Attachments
Bug 20501: Don't cut strings when unhighlighting in intranet search results (1.75 KB, patch)
2020-04-19 02:53 UTC, Phil Ringnalda
Details | Diff | Splinter Review
Bug 20501: Don't cut strings when unhighlighting in intranet search results (1.84 KB, patch)
2020-04-21 01:01 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
Bug 20501: Don't cut strings when unhighlighting in intranet search results (1.90 KB, patch)
2020-04-21 15:24 UTC, Josef Moravec
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Phil Ringnalda 2018-03-29 21:20:26 UTC
If you search in the staff client for the keyword apple, you can then unhighlight and hightlight again over and over without harm, but if you search for the keyword apple apple (or any other repeated word, the search that showed it to me was the word A in A giraffe and a half), when you click unhighlight the first instance of the repeated word is completely removed from each search result, and if you click highlight, and then click unhighlight again, the next instance will be removed each time you highlight/unhighlight.
Comment 1 Katrin Fischer 2018-03-30 10:43:25 UTC
Confirmed, also appears to be limited to staff, OPAC is ok.
Comment 2 Owen Leonard 2018-06-05 18:40:23 UTC
I cannot reproduce this problem in master. Can anyone confirm? If so please cite another example.
Comment 3 Phil Ringnalda 2018-06-14 16:38:08 UTC
Still present in master. How about the example from bug 5844, which fixed the copy of jquery.highlight-3.js in koha-tmpl/opac-tmpl/ but not the copy in koha-tmpl/intranet-tmpl/, "mag ma m"? All that's actually needed is to patch the intranet-tmpl copy the same way.

I don't quite see how an example can actually work, unless there's some standard set of bib records everyone has that I haven't yet run across documentation of, though. Before I realized why it only happens in the staff client, I was drafting a set of steps to reproduce that were going to start with "Create a bib record with the title A is for apple and another with the title A my name is Anna" since reproducing requires only that you have a search which in your database will return two or more records and will have matches in things which are displayed in the staff client search results list.

"a a" is actually a pretty good example since as long as you have two (or more) records in your database which contain the letter "a" in any indexed field, you will have highlights that will show the letter being removed from the DOM in the words "Material" and "Format" and "Literary" in the line "Material type: Book Format: print Literary form: Not fiction" even if you don't have highlights in the author or title. Might still fail for a non-English install, but otherwise it seems like the most likely to work in any install with any bib records.
Comment 4 Katrin Fischer 2018-06-19 21:46:15 UTC
I can reproduce this: I searched for "the the". Unhighlighting removes the first occurrence of the word in the result list. (intranet only)

From the sample data:
	The ideas behind the chess openings / Reuben Fine. 
Turns into:
	ideas behind the chess openings / Reuben Fine.
Comment 5 Phil Ringnalda 2020-04-19 02:53:44 UTC
Created attachment 103210 [details] [review]
Bug 20501: Don't cut strings when unhighlighting in intranet search results

When you click Unhighlight on the search results of a search in the staff client
when the search terms contain the same word twice, like "ma ma", the highlighted
words disappear, and don't reappear if you click Highlight.

This patch makes the same change to the intranet copy of jquery.highlight-3.js that
bug 5844 made to the OPAC copy.

Test plan:
1) Without this patch, search in the intranet for ma ma and verify you have at least
   two matching records.
2) Notice that the Ma in Material type: Book is highlighted.
3) Click Unhighlight, and notice that it has become terial type: Book
4) Apply this patch, repeat the search with a shift+reload to reload the .js
5) Click Unhighlight, and verify that Material type: Book remains Material
Comment 6 Bernardo Gonzalez Kriegel 2020-04-21 01:01:54 UTC
Created attachment 103319 [details] [review]
Bug 20501: Don't cut strings when unhighlighting in intranet search results

When you click Unhighlight on the search results of a search in the staff client
when the search terms contain the same word twice, like "ma ma", the highlighted
words disappear, and don't reappear if you click Highlight.

This patch makes the same change to the intranet copy of jquery.highlight-3.js that
bug 5844 made to the OPAC copy.

Test plan:
1) Without this patch, search in the intranet for ma ma and verify you have at least
   two matching records.
2) Notice that the Ma in Material type: Book is highlighted.
3) Click Unhighlight, and notice that it has become terial type: Book
4) Apply this patch, repeat the search with a shift+reload to reload the .js
5) Click Unhighlight, and verify that Material type: Book remains Material

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Work as described, no errors.
Comment 7 Josef Moravec 2020-04-21 15:24:01 UTC
Created attachment 103387 [details] [review]
Bug 20501: Don't cut strings when unhighlighting in intranet search results

When you click Unhighlight on the search results of a search in the staff client
when the search terms contain the same word twice, like "ma ma", the highlighted
words disappear, and don't reappear if you click Highlight.

This patch makes the same change to the intranet copy of jquery.highlight-3.js that
bug 5844 made to the OPAC copy.

Test plan:
1) Without this patch, search in the intranet for ma ma and verify you have at least
   two matching records.
2) Notice that the Ma in Material type: Book is highlighted.
3) Click Unhighlight, and notice that it has become terial type: Book
4) Apply this patch, repeat the search with a shift+reload to reload the .js
5) Click Unhighlight, and verify that Material type: Book remains Material

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Work as described, no errors.

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 8 Martin Renvoize (ashimema) 2020-04-22 08:31:56 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 9 Joy Nelson 2020-05-08 18:47:50 UTC
Backported to 19.11.x for 19.11.06
Comment 10 Lucas Gass (lukeg) 2020-05-14 18:14:00 UTC
backported to 19.05.x for 19.05.11