https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40643

Marcel de Rooy <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #185494|0                           |1
        is obsolete|                            |

--- Comment #6 from Marcel de Rooy <[email protected]> ---
Created attachment 185888
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=185888&action=edit
Bug 40643: Prevent keypress buildup in circulation

We have reports of progressive slowdown on the circulation page during
long sessions. A likely cause might be a block in `circ/circulation.tt`
that attaches a new keypress handler to `#barcode` on every submit. Some
submits do not navigate (e.g. waiting holds modal, quick slip on empty
barcode), and pages restored from the bfcache keep previously attached
handlers. Over time, listeners accumulate and the UI becomes sluggish.

This patch installs a single, namespaced keypress handler at page load,
guarded by an in-flight flag toggled on submit. The handler shows the
“Barcode submitted” modal and prevents typing only while a submit is
in flight. The flag is reset on bfcache restores via `pageshow`. This
preserves existing UX while keeping the listener count constant.

Test plan:
1. Before applying the patch, open circ/circulation.pl for any patron.
2. In the browser console, run:
   (function () {
     const el = $('#barcode')[0];
     const dataFn = jQuery._data || jQuery.data;
     const ev = (dataFn && dataFn(el, 'events')) || {};
     return (ev.keypress || []).length;
   })()
   Note the keypress handler count.
3. Enter a barcode and submit. Use the browser Back button to return.
4. Re-run the IIFE from step 2. The count has increased.
5. Repeat steps 3–4 a few times and observe the count continues to grow.
6. Apply the patch.
7. Reload the page and re-run step 2; count should be ~1.
8. Enter a barcode and submit. Use Back to return. Re-run step 2.
   The count remains ~1 across submits and back/forward navigations.
9. Confirm UX is preserved:
   - While submit is in flight, pressing keys in `#barcode` shows the
     “Barcode submitted” modal and prevents typing.
   - Waiting holds flow still shows its modal and behaves as before.
   - Submitting with an empty barcode still triggers the quick slip
     behavior per system preference and does not add handlers.
10. Optional: Simulate scanner behavior by pressing Enter rapidly after
    submit. Verify the handler count remains stable.

Signed-off-by: krimsonkharne <[email protected]>

Signed-off-by: Marcel de Rooy <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to