Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): keep the jump button in view, show actions on Tab in
Yudhi Armyndharisc532ac6768b8
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 403b95c23..0ecfa09a1 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -51,6 +51,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Fixed- Bound each webhook and ingress queue command at 2 s once Redis has connected, so a Redis that stops answering falls back to direct delivery and inline dispatch instead of holding every dispatch and ingress request.+- Keep the dashboard chat's scroll-to-bottom button in view while the reader is scrolled up, where it moved with the thread and was off screen.- Refuse to save a local `storage.localPath` the app cannot create or write, where the next start refused to boot and the dashboard that could undo the save was down.- Answer `400` for a send route's or a product send's `chatId`, or a bulk `batchId`, over 255 characters, where PostgreSQL answered `500` once the value passed its index entry limit.- Answer `400` for a chat action's `chatId` over 255 characters, as the send routes do, instead of handing it to the engine.diff --git a/dashboard/src/components/chats/ChatThread.test.ts b/dashboard/src/components/chats/ChatThread.test.tsindex cf9051288..52082667d 100644--- a/dashboard/src/components/chats/ChatThread.test.ts+++ b/dashboard/src/components/chats/ChatThread.test.ts@@ -562,3 +562,32 @@ test('a click marks pointer use, a key press clears it, and the stylesheet reveaassert.ok(rule.includes('.room-messages:not([data-pointer])'), `${target} is gated on keyboard modality`);}});++// The button is a child of the scroller. Absolutely positioned there it moves with the content, which put it+// at the bottom of the first screen of the thread and off screen whenever it was shown. Sticky, as the last+// child, it holds to the bottom of the visible pane. jsdom has no layout, so the declaration is pinned.+test('the scroll-to-bottom button is sticky inside the scroller, not absolute', () => {+ const css = readFileSync(new URL('../../pages/Chats.css', import.meta.url), 'utf8');+ const rule = /\.chats-page \.scroll-to-bottom-btn \{([^}]*)\}/.exec(css)?.[1] ?? '';+ assert.match(rule, /position:\s*sticky;/);+ assert.match(rule, /bottom:\s*1rem;/);+ assert.doesNotMatch(rule, /position:\s*absolute/);+});++// A Tab from the sidebar into the thread is a key press the thread never sees, so a click made in the thread+// earlier left the pointer mark on, and the focused bubble showed no actions until the next key. A focus+// the browser calls keyboard focus (:focus-visible) clears the mark; the focus a click brings does not match.+test('focus that arrives by keyboard clears the pointer mark a click left, and a mouse focus does not', () => {+ const { container } = renderThread('operator', [PROMPT, { ...PROMPT, id: 'db-2', waMessageId: 'wamid.2' }]);+ const thread = container.querySelector<HTMLElement>('.room-messages');+ assert.ok(thread);+ const bubble = bubblesOf(container)[0];++ rtl.fireEvent.pointerDown(bubble);+ // A focus event on an element that is not the focused one has no :focus-visible, as a click's does not.+ rtl.fireEvent.focusIn(bubble);+ assert.equal(thread.hasAttribute('data-pointer'), true);++ bubble.focus();+ assert.equal(thread.hasAttribute('data-pointer'), false);+});diff --git a/dashboard/src/components/chats/ChatThread.tsx b/dashboard/src/components/chats/ChatThread.tsxindex ced9e45c9..8c8375aec 100644--- a/dashboard/src/components/chats/ChatThread.tsx+++ b/dashboard/src/components/chats/ChatThread.tsx@@ -267,36 +267,25 @@ function ChatThread({return new Date(timestamp * 1000).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });};- // position:relative so the scroll-to-bottom button can float inside.return (<divclassName="room-messages"ref={messagesContainerRef}// The actions show while focus is inside a bubble, but only for keyboard focus: a click also focuses// the bubble, and its menu would stay drawn over the message after the pointer left. The marker is- // read by Chats.css.+ // read by Chats.css. Focus that a key press brings in from outside the thread clears it as well: the+ // key was pressed elsewhere, so no keydown reached this element, and the marker a click left would+ // keep the menu of the focused bubble hidden until the next key.onPointerDown={event => event.currentTarget.setAttribute('data-pointer', '')}onKeyDown={event => event.currentTarget.removeAttribute('data-pointer')}- onFocus={() => {+ onFocus={event => {focusInThreadRef.current = true;+ if (event.target.matches(':focus-visible')) event.currentTarget.removeAttribute('data-pointer');}}onBlur={event => {if (!event.currentTarget.contains(event.relatedTarget as Node | null)) focusInThreadRef.current = false;}}>- {/* Floating scroll-to-bottom button. Hidden while loading (no height to measure yet)- and when the user is already at/near the bottom. */}- {showJumpToBottom && !loadingMessages && (- <button- type="button"- className="scroll-to-bottom-btn"- onClick={handleJumpToBottom}- aria-label={t('chats.scrollToBottom')}- title={t('chats.scrollToBottom')}- >- <ChevronDown size={22} />- </button>- )}{/* Older-page spinner, or the failure in its place. An in-flow sibling before the thread, notan overlay — it pushes the oldest bubble down, which is why useChatScrollPosition readsthis container's height at REQUEST time (before this renders), not on whichever commit@@ -675,6 +664,21 @@ function ChatThread({);}))}+ {/* Floating scroll-to-bottom button. The LAST child, so that `position: sticky; bottom` holds it at+ the bottom of the visible pane while the thread scrolls under it: absolutely positioned inside+ the scroller it moved with the content and was off screen whenever it was shown. Hidden while+ loading (no height to measure yet) and when the user is already at/near the bottom. */}+ {showJumpToBottom && !loadingMessages && (+ <button+ type="button"+ className="scroll-to-bottom-btn"+ onClick={handleJumpToBottom}+ aria-label={t('chats.scrollToBottom')}+ title={t('chats.scrollToBottom')}+ >+ <ChevronDown size={22} />+ </button>+ )}</div>);}diff --git a/dashboard/src/pages/Chats.css b/dashboard/src/pages/Chats.cssindex 0d8aa5602..cd40630cd 100644--- a/dashboard/src/pages/Chats.css+++ b/dashboard/src/pages/Chats.css@@ -453,13 +453,18 @@}/* Floating scroll-to-bottom button. Sits at the bottom-right of the messages pane (not the footer)- so it overlays the conversation without stealing input-bar space. The default desktop scrollbar- gutter leaves ~15px to the right edge; we anchor a bit further in so the button doesn't overlap- the scrollbar on narrow viewports. */+ so it overlays the conversation without stealing input-bar space. It is the last child of the+ scroller and sticky, not absolute: an absolute child of the scroller moves with the content, so it+ sat at the bottom of the first screen of the thread, off screen whenever it was shown. In flow it+ would add its own height and one flex gap to the thread, which the negative margin takes back, so+ the scroll height is the same with and without it (the gap is the 0.75rem of .room-messages). The+ right edge is the scroller's padding, clear of the scrollbar. */.chats-page .scroll-to-bottom-btn {- position: absolute;- right: 1.5rem;+ position: sticky;bottom: 1rem;+ align-self: flex-end;+ flex: none;+ margin-top: calc(-40px - 0.75rem);z-index: 5;width: 40px;height: 40px;