View Issue Details

IDProjectCategoryView StatusLast Update
0012022Talermerchant portal webuipublic2026-11-18 17:07
Reporterbot-cg [agent]  
CommunicatorCM_7  
PrioritynormalSeveritytrivial 
Status closedResolutionfixed 
Target Version1.6Fixed in Version1.6 
Summary0012022: Merchant PoS: ad-hoc item and quick-refund dialogs, and the paid screen, do not focus what they ask for
DescriptionWhat happens:
Web PoS: (1) '+ Ad-hoc Item' opens 'Add Ad-hoc Custom Item' - focus stays on the '+ Ad-hoc Item' button behind the overlay. (2) Till History -> '↩ Issue Refund' opens the refund dialog - focus stays on the row button behind it, also after the remaining amount has loaded; when nothing is left to refund the amount stays disabled and focus is still behind. (3) When the customer pays, the till switches to 'Payment Successful!' - focus is wherever it was (BODY in the real flow) instead of the only action.

Expected:
(1) Item Description input. (2) Refund amount once enabled (after the order's remainder loads), otherwise Cancel. (3) 'Start New Sale' button, so the cashier can press Enter.

Where:
  - packages/taler-merchant-webui/src/screens/PosScreen.tsx:290
  - packages/taler-merchant-webui/src/screens/PosScreen.tsx:1291
  - packages/taler-merchant-webui/src/screens/PosScreen.tsx:1415
  - packages/taler-merchant-webui/src/screens/PosScreen.tsx:1485
  - packages/taler-merchant-webui/src/screens/PosScreen.tsx:1541

Measured in headless Chromium (document.activeElement):
  before: ad-hoc: BUTTON '+ Ad-hoc Item' (behind overlay); refund: BUTTON '↩ Issue Refund' (behind overlay), also when fully refunded; success: unchanged previous focus
  after: ad-hoc: INPUT[text] description; refund: INPUT[number] amount; fully refunded: BUTTON 'Cancel'; success: BUTTON#pos_new_sale_btn (other shots: merchant-b--pos-custom-item-dialog--*.png, merchant-b--pos-success-step--*.png)

Proposed fix:
Refs plus three effects: on showCustomModal -> description input; on refundOrderId/isRefundDetailsLoading settling -> amount input if enabled, else Cancel; on activeTab === 'success' -> Start New Sale button.

Patch against taler-typescript-core master attached; the same change is committed on branch dev/bots/autofocus (durian). Screenshots attached (focused element outlined in red): 'before' is master, 'after' is with the patch.

Verified: tsc ok for file; screens.test.js passes; screenshots confirm
TagsNo tags attached.
Attached Files
merchant-b--pos-dialogs-and-success.diff (2,797 bytes)   
diff --git a/packages/taler-merchant-webui/src/screens/PosScreen.tsx b/packages/taler-merchant-webui/src/screens/PosScreen.tsx
index d324f83f3..bfe0cc4a8 100644
--- a/packages/taler-merchant-webui/src/screens/PosScreen.tsx
+++ b/packages/taler-merchant-webui/src/screens/PosScreen.tsx
@@ -285,6 +285,26 @@ export function PosScreen({
   const [isRefundDetailsLoading, setIsRefundDetailsLoading] =
     useState<boolean>(false);
 
+  // Each overlay and the paid screen asks for one thing first; put focus there
+  // when it appears instead of leaving it on the control behind the overlay.
+  const customDescInput = useRef<HTMLInputElement>(null);
+  const refundAmountInput = useRef<HTMLInputElement>(null);
+  const refundCancelButton = useRef<HTMLButtonElement>(null);
+  const newSaleButton = useRef<HTMLButtonElement>(null);
+  useEffect(() => {
+    if (showCustomModal) customDescInput.current?.focus();
+  }, [showCustomModal]);
+  // The refund amount stays disabled until the order's refundable remainder
+  // has loaded; if nothing is left to refund, only Cancel is useful.
+  useEffect(() => {
+    if (!refundOrderId || isRefundDetailsLoading) return;
+    const amount = refundAmountInput.current;
+    (amount && !amount.disabled ? amount : refundCancelButton.current)?.focus();
+  }, [refundOrderId, isRefundDetailsLoading]);
+  useEffect(() => {
+    if (activeTab === "success") newSaleButton.current?.focus();
+  }, [activeTab]);
+
   const { copied: copiedPayUrl, error: copyPayUrlError, copy } = useClipboard();
 
   // Which order the caller last asked for. Seeded with the mount value so the
@@ -1268,6 +1288,7 @@ export function PosScreen({
               )}
 
               <button
+                ref={newSaleButton}
                 type="button"
                 id="pos_new_sale_btn"
                 onClick={() => {
@@ -1391,6 +1412,7 @@ export function PosScreen({
                   {t`Item Description *`}
                 </label>
                 <input
+                  ref={customDescInput}
                   type="text"
                   required
                   placeholder={t`e.g. Custom Bakery Gift Set`}
@@ -1460,6 +1482,7 @@ export function PosScreen({
                   {t`Refund Amount (${Amounts.amountCurrency(refundDetails?.remaining) || "—"}) *`}
                 </label>
                 <input
+                  ref={refundAmountInput}
                   type="number"
                   step="any"
                   required
@@ -1515,6 +1538,7 @@ export function PosScreen({
                 title={t`Failed to issue refund.`}
               >
                 <button
+                  ref={refundCancelButton}
                   type="button"
                   onClick={() => {
                     setRefundOrderId(null);

Required notifications

Address or linkRemarkAdded byNotifiedActions

Relationships

child of 0012002 closed Merchant portal: dialogs, PIN/code prompts and single-purpose forms open without keyboard focus on the obvious field 

Activities

bot-codex-florian-dold

2026-11-13 09:11

manager   ~0030471

commit bdcd9f94c2c1e3c0c8649255029c53c3b9a011de
Author: Florian Dold <dold@taler.net>
Date: Fri Nov 13 01:06:16 2026 +0100

    merchant web UI: focus PoS item, refund and next-sale controls
    
    Focus the item description on entry, the refund amount after loading,
    and Start New Sale after payment. Leave focus on Cancel if no refund
    amount can be entered.
    
    Issue: https://bugs.taler.net/n/12022
    Assisted-by: LLM

commit 0db14837db18a79a4bee3ca81c0137bc20c01f92
Author: Florian Dold <dold@taler.net>
Date: Fri Nov 13 01:06:14 2026 +0100

    web-util: restore dialog openers and coordinate nested dialogs
    
    DialogFocusScope adds Escape handling and opener restoration to a focus
    scope. Hooks provide the same behavior for existing wrappers. Menus
    restore focus without trapping it; native dialogs retain browser Tab
    handling.
    
    After an initial request succeeds, discard the other eligible requests,
    including ones tried earlier while their controls were unavailable. Keep
    requests blocked by a modal and requests waiting after fallback focus.
    
    Issue: https://bugs.taler.net/n/12002
    Issue: https://bugs.taler.net/n/12024
    Issue: https://bugs.taler.net/n/12034
    Assisted-by: LLM

commit c1ee0c1022645200e605a3f36ab4910a3750c180
Author: Florian Dold <dold@taler.net>
Date: Fri Nov 13 01:06:11 2026 +0100

    web-util: focus pages and form steps when their controls are ready
    
    FocusScope queues one initial focus request when a page, form or step
    opens. It waits for loading and cancels the request if the user moves
    focus. useFocusTarget retries pending focus when a control mounts.
    
    Explicit requestFocus calls run immediately and return success or
    failure.
    
    Issue: https://bugs.taler.net/n/12002
    Issue: https://bugs.taler.net/n/12024
    Assisted-by: LLM

Issue History

Date ModifiedUsernameFieldChange
2026-11-10 23:41bot-cgNew Issue
2026-11-10 23:41bot-cgRelationship addedchild of 0012002
2026-11-10 23:43bot-cgFile Added: merchant-b--pos-dialogs-and-success.diff
2026-11-10 23:43bot-cgFile Added: merchant-b--pos-refund-dialog--before.png
2026-11-10 23:43bot-cgFile Added: merchant-b--pos-refund-dialog--after.png
2026-11-11 08:25Christian GrothoffSeverityminor => trivial
2026-11-13 09:11bot-codex-florian-doldNote Added: 0030471
2026-11-13 09:12bot-codex-florian-doldStatusnew => closed
2026-11-13 09:12bot-codex-florian-doldResolutionopen => fixed
2026-11-18 17:03Christian GrothoffTarget Version => 1.6
2026-11-18 17:07Christian GrothoffFixed in Version => 1.6