Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
718ab9e
Build a blueprint
compulim Nov 26, 2025
b98f4ff
Add focus trap
compulim Nov 26, 2025
8ab4310
Simple styling
compulim Nov 26, 2025
373f0e8
Change to <section>
compulim Nov 26, 2025
35cd62e
Add comment
compulim Nov 26, 2025
b0b2073
Remove bodyId
compulim Nov 26, 2025
454380b
Remove role="none"
compulim Nov 26, 2025
6e0e886
Add CSS comments
compulim Nov 26, 2025
62e9278
Remove commented code
compulim Nov 26, 2025
ca02096
Add tests for ideal scenario
compulim Dec 2, 2025
0e453a9
Add tests
compulim Dec 2, 2025
6be4380
Remove deprecated test
compulim Dec 2, 2025
b6b2f44
Add tests
compulim Dec 2, 2025
bb46a22
Clean up
compulim Dec 2, 2025
f9cfb6d
Clean up
compulim Dec 2, 2025
1c15961
Refactor id
compulim Dec 2, 2025
ad0343e
Use ID to save active message
compulim Dec 2, 2025
c624252
Keep position after message added
compulim Dec 3, 2025
42bffe3
Longer timeout
compulim Dec 3, 2025
c0dede7
Add ALT+A
compulim Dec 3, 2025
dc82423
Move to roving tab index
compulim Dec 4, 2025
dfa3758
Simplify ChatMessage API
compulim Dec 4, 2025
7ab539c
Comments
compulim Dec 4, 2025
90296bd
Fix ESCAPE to send box
compulim Dec 4, 2025
39e5e33
Remove console
compulim Dec 4, 2025
8fc4b72
Simplify unnecessary deps
compulim Dec 4, 2025
5422c7a
No need roving tab index
compulim Dec 4, 2025
0b37b6b
Clean up
compulim Dec 4, 2025
2b3d585
Use useId()
compulim Dec 4, 2025
8d223a4
TAB and SHIFT-TAB will send focus into focus trap
compulim Dec 4, 2025
63654f0
Add @ts-ignore on useId
compulim Dec 4, 2025
cc296a6
Unify keydown
compulim Dec 4, 2025
2bc5bcb
Clean up
compulim Dec 4, 2025
71e68db
Clean up some code
compulim Dec 4, 2025
b2b26ef
Use jumpToRelativeMessage to reduce reliance on focusedMessageId
compulim Dec 4, 2025
45530c2
Comments
compulim Dec 4, 2025
fe0185b
Add comments
compulim Dec 4, 2025
b5e1b2c
Add comments
compulim Dec 4, 2025
1dbe157
Fix clause
compulim Dec 4, 2025
0dc30cb
Add Adaptive Card
compulim Dec 4, 2025
1184a71
Remove unused id
compulim Dec 4, 2025
e74e37d
Add attachment label
compulim Dec 4, 2025
e97edf0
Add Windows Narrator quirks comment
compulim Dec 4, 2025
35eca65
Add interact mode 2
compulim Dec 5, 2025
ed94d8b
Reduce reading in mode 2
compulim Dec 5, 2025
61bf2c2
Arrow to move between chat history and send box
compulim Dec 6, 2025
5ed93d3
Better CSS
compulim Dec 6, 2025
82b54c7
Clean up comments
compulim Dec 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests
  • Loading branch information
compulim committed Dec 2, 2025
commit b6b2f440fb9e5c7d6e4af03899b97eb5b9b1d5bf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<link href="./static/index.css" rel="stylesheet" type="text/css" />
</head>
<body>
<main></main>
<script type="module">
import '/test-harness.mjs';
import '/test-page-object.mjs';

import { render, systemUnderTest } from './static/index.js';

run(
async function () {
await render();

systemUnderTest.chatHistory.focus();
await host.sendKeys('ARROW_UP');
await host.sendKeys('ENTER');

expect(document.activeElement).toBe(systemUnderTest.chatMessageBodies[1]);
expect(systemUnderTest.activeChatMessage).toBe(systemUnderTest.chatMessages[1]);
expect(systemUnderTest.activeDescendant).toBe(systemUnderTest.chatMessages[1]);

await host.sendTab();

// THEN: Should not move the focus.
expect(document.activeElement).toBe(systemUnderTest.chatMessageBodies[1]);
expect(systemUnderTest.activeChatMessage).toBe(systemUnderTest.chatMessages[1]);
expect(systemUnderTest.activeDescendant).toBe(systemUnderTest.chatMessages[1]);
},
{ skipCheckAccessibility: true }
);
</script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function FocusTrap({ children, onEscapeKeyDown }) {
element => !element.closest('[inert]') && element.offsetParent
);

if (focusables.length === 0) {
if (!focusables.length) {
return;
}

Expand Down Expand Up @@ -134,6 +134,17 @@ function ChatMessage({ abstract, activeMode, children, index, onActive, onLeave,
event.stopPropagation();

onLeaveRef.current?.();
} else if (event.key === 'Tab' && event.target === bodyRef.current) {
// Special case: regardless if the content is interactive or not, trap the TAB key.

// TODO: Can we make this simpler? Says, if we merge <div data-testid="chat message body"> with <FocusTrap>, will it makes this simpler?
const focusables = Array.from<HTMLElement>(bodyRef.current?.querySelectorAll(FOCUSABLE_SELECTOR_QUERY)).filter(
element => !element.closest('[inert]') && element.offsetParent
);

if (!focusables.length) {
event.preventDefault();
}
}
},
[onLeaveRef]
Expand Down Expand Up @@ -246,8 +257,6 @@ function ChatHistory({ onLeave }) {
messagesRef.at(activeMessageIndex === Infinity ? -1 : activeMessageIndex).current?.focus();
} else if (event.key === 'Escape') {
// We like this, when pressing ESCAPE key on chat history, send the focus to send box.
// setIsMessageFocused(false);

onLeaveRef.current?.();
} else if (event.key === 'Tab') {
// When tabbing out of chat history, skip all message bodies.
Expand Down