feat(pos): configurable idle auto-focus for item search#309
Open
NotAbdelrahmanelsayed wants to merge 2 commits into
Open
feat(pos): configurable idle auto-focus for item search#309NotAbdelrahmanelsayed wants to merge 2 commits into
NotAbdelrahmanelsayed wants to merge 2 commits into
Conversation
Make the idle "snap focus back to the item search" behavior a native, configurable POS setting instead of relying on the external easy_entry app's hardcoded pos_guard.js (fixed 3s). Two new POS Settings (Advanced): - enable_idle_refocus (Check, default 1 — preserves today's behavior) - idle_refocus_seconds (Int, default 3, depends_on enable_idle_refocus) Wired through every layer: doctype JSON, constants.py (POS_SETTINGS_FIELDS + DEFAULT_POS_SETTINGS), posSettings store (defaults + computeds + exports), and the settings dialog (checkbox + conditional seconds field in Sales Operations). New composable useIdleRefocus.js refocuses the item search after the configured idle interval, with the pos_guard.js guards ported over: never steal focus from another text field (customer search, quantity edit) and never fight an open dialog. It reacts to the settings live (enable/interval) and cleans up on unmount. Wired in POSSale.vue, which owns itemsSelectorRef and the UI store. Adds unit tests for the timer/guard logic and Arabic translations. Note: the easy_entry pos_guard.js still targets the SPA and now duplicates this behavior; retiring it is a follow-up in that separate app/repo. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…e-autofocus # Conflicts: # POS/src/stores/posSettings.js # pos_next/translations/ar.csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the idle "return focus to the item search" behavior a native, configurable POS setting, replacing reliance on the external
easy_entryapp's hardcodedpos_guard.js(fixed 3s, not configurable).New POS Settings (Advanced)
enable_idle_refocus(Check, default 1) — preserves today's behavior out of the box.idle_refocus_seconds(Int, default 3,depends_onenable_idle_refocus) — idle seconds before refocus.Wired through every layer so the value actually reaches the SPA: doctype JSON,
constants.py(POS_SETTINGS_FIELDSandDEFAULT_POS_SETTINGS), theposSettingsstore (defaults + computeds + exports), and the settings dialog (checkbox + conditional seconds field).Implementation
New composable
useIdleRefocus.js:pos_guard.jsuserIsBusy: never steals focus from another text field (customer search, quantity edit) and never fights an open dialog (uiStore.isAnyDialogOpen).POSSale.vue, which ownsitemsSelectorRefand the UI store.Tests & i18n
useIdleRefocus.test.js(5 cases): fires after the interval, stays off when disabled, holds off while a dialog is open, doesn't steal focus from another input, and re-evaluates the interval reactively.ar.csv) entries for the two new setting labels/descriptions.Verification
npm run test:run— all pass.npm run build— compiles cleanly.Deployment note
The new doctype fields require
bench migrateand (for theconstants.pychange) a gunicorn reload on deploy — not run here against the shared site.Follow-up (separate repo)
easy_entry'spos_guard.jsstill targets the SPA and now duplicates this behavior; retiring/disabling it there is a follow-up.🤖 Generated with Claude Code