Skip to content

feat(pos): configurable idle auto-focus for item search#309

Open
NotAbdelrahmanelsayed wants to merge 2 commits into
BrainWise-DEV:developfrom
NotAbdelrahmanelsayed:feat/configurable-autofocus
Open

feat(pos): configurable idle auto-focus for item search#309
NotAbdelrahmanelsayed wants to merge 2 commits into
BrainWise-DEV:developfrom
NotAbdelrahmanelsayed:feat/configurable-autofocus

Conversation

@NotAbdelrahmanelsayed

Copy link
Copy Markdown
Contributor

Summary

Makes the idle "return focus to the item search" behavior a native, configurable POS setting, replacing reliance on the external easy_entry app's hardcoded pos_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_on enable_idle_refocus) — idle seconds before refocus.

Wired through every layer so the value actually reaches the SPA: doctype JSON, constants.py (POS_SETTINGS_FIELDS and DEFAULT_POS_SETTINGS), the posSettings store (defaults + computeds + exports), and the settings dialog (checkbox + conditional seconds field).

Implementation

New composable useIdleRefocus.js:

  • After the configured idle interval, refocuses the item search input.
  • Guards ported from pos_guard.js userIsBusy: never steals focus from another text field (customer search, quantity edit) and never fights an open dialog (uiStore.isAnyDialogOpen).
  • Reacts live to the settings (enable toggle + interval) and cleans up on unmount.
  • Wired in POSSale.vue, which owns itemsSelectorRef and 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.
  • Arabic (ar.csv) entries for the two new setting labels/descriptions.

Verification

  • npm run test:run — all pass. npm run build — compiles cleanly.
  • Manual screenshot review against a live backend: confirmed the settings checkbox + conditional seconds field render and toggle correctly; verified the item search refocuses ~3s after a real activity event, does not refocus before the threshold, and does not steal focus while typing in the customer search.

Deployment note

The new doctype fields require bench migrate and (for the constants.py change) a gunicorn reload on deploy — not run here against the shared site.

Follow-up (separate repo)

easy_entry's pos_guard.js still targets the SPA and now duplicates this behavior; retiring/disabling it there is a follow-up.

🤖 Generated with Claude Code

NotAbdelrahmanelsayed and others added 2 commits June 12, 2026 15:56
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant