Error unchecking Exclude Electronic Resources when locale picker is enabled

Bug #1847343 reported by Jeff Davis
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Evergreen
Fix Released
Medium
Unassigned
3.3
Won't Fix
Undecided
Unassigned
3.4
Fix Released
Undecided
Unassigned

Bug Description

EG 3.3.4, other versions likely affected

When the locale picker is enabled, the OPAC's "Exclude Electronic Resources" checkbox works as expected if you check it to exclude the resources. However, if you uncheck it while on the search results page, the box disappears and the page doesn't refresh to show you your results including electronic resources.

When you exclude electronic resources from a search, the results page includes a hidden input field:

<input type="hidden" name="fi:-search_format" value="electronic" />

When there is no locale picker, the only form on the results page is the search form, and the hidden input gets added to it. But if the locale picker is enabled, your results page has *two* forms, and the hidden input gets added to the first one, i.e. the locale picker form instead of the search form. Then, when you uncheck the Exclude Electronic Resources checkbox, a Javascript function tries to remove the hidden input, but it can't find it (because it's in the wrong form); it removes the checkbox instead, and you get an error on checkbox.form.submit().

Revision history for this message
Jeff Davis (jdavis-sitka) wrote :

Steps to reproduce:

[1] In eg_vhost.conf, under <Location /eg>, uncomment OILSWebLocale entries to enable multiple locales and display the locale picker.
[2] Restart Apache.
[3] Do a search.
[4] On the results page, check the "Exclude Electronic Resources" box. The page will refresh as your search is resubmitted with e-resources excluded.
[5] On the new results page, uncheck the "Exclude Electronic Resources" box. The checkbox disappears, the page is not refreshed, and the JS console shows a "TypeError: checkbox.form is null" error on exclude_onchange().

Revision history for this message
Jeff Davis (jdavis-sitka) wrote :

Working branch user/jeffdavis/lp1847343-exclude-eresources-fix has a fix:

https://git.evergreen-ils.org/?p=working/Evergreen.git;a=shortlog;h=refs/heads/user/jeffdavis/lp1847343-exclude-eresources-fix

I'm not 100% sure why the locale picker causes problems but I assume there are issues removing multiple hidden input elements. Adding type="hidden" as a criterion and switching from getElementsByName to querySelectorAll in the exclude_onchange() function seems to do the trick.

Test plan:
[1] In config.tt2, enable Exclude Electronic Resources checkbox: ctx.exclude_electronic_checkbox = 1;
[2] In eg_vhost.conf, under <Location /eg>, uncomment OILSWebLocale entries to enable multiple locales and display the locale picker.
[3] Restart Apache.
[4] Do a search.
[5] On the results page, check the "Exclude Electronic Resources" box. The page will refresh as your search is resubmitted with e-resources excluded.
[6] On the new results page, uncheck the "Exclude Electronic Resources" box. The checkbox disappears, the page is not refreshed, and the JS console shows a "TypeError: checkbox.form is null" error on exclude_onchange().
[7] Apply the fix.
[8] Clear cache and repeat steps 4-6. Unchecking the "Exclude Electronic Resources" box should now refresh the page to show results including electronic resources.

Changed in evergreen:
milestone: none → 3.4.1
tags: added: pullrequest
Changed in evergreen:
milestone: 3.4.1 → 3.4.2
Changed in evergreen:
milestone: 3.4.2 → 3.4.3
Changed in evergreen:
milestone: 3.4.3 → 3.5.0
Changed in evergreen:
milestone: 3.5.0 → 3.5.1
Changed in evergreen:
status: New → Confirmed
importance: Undecided → Medium
tags: added: i18n opac signedoff
Revision history for this message
Jane Sandberg (sandbergja) wrote :

Issue confirmed, and your patch fixed it for me. Thanks, Jeff. Signoff at user/sandbergja/lp1847343-exclude-eresources-fix-signoff

Revision history for this message
Galen Charlton (gmc) wrote :

Pushed to master, rel_3_5, and rel_3_4. Thanks, Jeff and Jane!

Changed in evergreen:
status: Confirmed → Fix Committed
Changed in evergreen:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.