commit bdcd9f94c2c1e3c0c8649255029c53c3b9a011de
parent 073d2e7f48bb3ba51738e900ae533a2e0dc80876
Author: Florian Dold <dold@taler.net>
Date: Fri, 13 Nov 2026 01:06:16 +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
Diffstat:
1 file changed, 44 insertions(+), 12 deletions(-)
diff --git a/packages/taler-merchant-webui/src/screens/PosScreen.tsx b/packages/taler-merchant-webui/src/screens/PosScreen.tsx
@@ -14,6 +14,7 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
+import { useFocusScope } from "@gnu-taler/web-util/browser";
import { FormActionFooter, useFormFeedback } from "../ui/FormActionFooter.js";
import type { VNode } from "preact";
import { useState, useEffect, useRef } from "preact/hooks";
@@ -285,6 +286,19 @@ 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);
+ // The refund amount stays disabled until the order's refundable remainder
+ // has loaded; if nothing is left to refund, only Cancel is useful.
+ useFocusScope({
+ active: activeTab === "success",
+ initialFocus: () => newSaleButton.current,
+ });
+
const { copied: copiedPayUrl, error: copyPayUrlError, copy } = useClipboard();
// Which order the caller last asked for. Seeded with the mount value so the
@@ -1268,6 +1282,7 @@ export function PosScreen({
)}
<button
+ ref={newSaleButton}
type="button"
id="pos_new_sale_btn"
onClick={() => {
@@ -1377,11 +1392,13 @@ export function PosScreen({
{/* Ad-hoc Custom Item Modal */}
{showCustomModal && (
- <div
- role="dialog"
- aria-modal="true"
- aria-label={t`Issue Refund for Order #${refundOrderId}`}
- class="fixed inset-0 bg-black/40 flex items-center justify-center p-4 z-50"
+ <Modal
+ isOpen
+ bare
+ onClose={() => setShowCustomModal(false)}
+ initialFocus={() => customDescInput.current}
+ ariaLabel={t`Add Ad-hoc Custom Item`}
+ overlayClass="fixed inset-0 bg-black/40 flex items-center justify-center p-4 z-50"
>
<div class="bg-white rounded-2xl max-w-sm w-full p-6 shadow-xl space-y-4 max-h-[90dvh] overflow-y-auto">
<h3 class="text-sm font-extrabold text-gray-900">{t`Add Ad-hoc Custom Item`}</h3>
@@ -1391,6 +1408,7 @@ export function PosScreen({
{t`Item Description *`}
</label>
<input
+ ref={customDescInput}
type="text"
required
placeholder={t`e.g. Custom Bakery Gift Set`}
@@ -1437,16 +1455,28 @@ export function PosScreen({
</div>
</form>
</div>
- </div>
+ </Modal>
)}
{/* Quick Refund Execution Modal */}
{refundOrderId && (
- <div
- role="dialog"
- aria-modal="true"
- aria-label={t`Issue Refund for Order #${refundOrderId}`}
- class="fixed inset-0 bg-black/40 flex items-center justify-center p-4 z-50"
+ <Modal
+ ready={!isRefundDetailsLoading}
+ fallbackFocus={() => refundCancelButton.current}
+ isOpen
+ bare
+ onClose={() => {
+ if (!isRefunding) setRefundOrderId(null);
+ }}
+ initialFocus={() =>
+ !isRefundDetailsLoading &&
+ refundAmountInput.current &&
+ !refundAmountInput.current.disabled
+ ? refundAmountInput.current
+ : refundCancelButton.current
+ }
+ ariaLabel={t`Issue Refund for Order #${refundOrderId}`}
+ overlayClass="fixed inset-0 bg-black/40 flex items-center justify-center p-4 z-50"
>
<div class="bg-white rounded-2xl max-w-sm w-full p-6 shadow-xl space-y-4 max-h-[90dvh] overflow-y-auto">
<h3 class="text-sm font-extrabold text-gray-900">{t`Issue Refund for Order #${refundOrderId}`}</h3>
@@ -1460,6 +1490,7 @@ export function PosScreen({
{t`Refund Amount (${Amounts.amountCurrency(refundDetails?.remaining) || "—"}) *`}
</label>
<input
+ ref={refundAmountInput}
type="number"
step="any"
required
@@ -1515,6 +1546,7 @@ export function PosScreen({
title={t`Failed to issue refund.`}
>
<button
+ ref={refundCancelButton}
type="button"
onClick={() => {
setRefundOrderId(null);
@@ -1536,7 +1568,7 @@ export function PosScreen({
</FormActionFooter>
</form>
</div>
- </div>
+ </Modal>
)}
</RawLayout>
);