Skip to content

Commit 374eb60

Browse files
committed
wip: scope useKeyboardNavigation to specific bot instance
1 parent 9848403 commit 374eb60

File tree

6 files changed

+130
-98
lines changed

6 files changed

+130
-98
lines changed

build/static/js/main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/static/js/main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ <h3>Bot Configuration</h3>
2222
<label for="user-logged-in">User logged in</label>
2323
<i>(toggle to control the bots login state)</i>
2424
</div>
25-
25+
2626
<div class="form-group">
2727
<label for="user-email">User Email:</label>
2828
<input type="email" id="user-email" placeholder="[email protected]" />
2929
</div>
30-
30+
3131
<div class="form-group">
3232
<label for="user-name">User Name:</label>
3333
<input type="text" id="user-name" placeholder="John Doe" />
3434
</div>
35-
35+
3636
<div class="form-group">
3737
<label for="accessId">ACCESS ID:</label>
3838
<input type="text" id="accessId" placeholder="johndoe123" />
3939
</div>
40-
40+
4141
<button id="update-bot" class="update-button">Update Bot Configuration</button>
4242
<p class="help-text">Enter user information above and click "Update Bot Configuration" to test pre-populated ticket forms when logged in.</p>
4343
</div>

local-demo.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ function recreateBots() {
9191
bot2Controller.destroy();
9292
bot2Controller = null;
9393
}
94-
94+
9595
// Clear containers
9696
document.getElementById('qa-bot').innerHTML = '';
9797
document.getElementById('custom-qa-bot').innerHTML = '';
98-
98+
9999
// Recreate with new user info
100100
initializeQABot();
101101
initializeEmbeddedBot();

src/components/QABot.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const QABotInternal = React.forwardRef((props, botRef) => {
6161
const sessionIdRef = useRef(getOrCreateSessionId());
6262
const sessionId = sessionIdRef.current;
6363
const [currentQueryId, setCurrentQueryId] = useState(null);
64-
64+
6565
// Use Form Context instead of local state
6666
const { ticketForm, feedbackForm, updateTicketForm, updateFeedbackForm, resetTicketForm, resetFeedbackForm } = useFormContext();
6767

@@ -107,15 +107,15 @@ const QABotInternal = React.forwardRef((props, botRef) => {
107107

108108
const handleQuery = useHandleAIQuery(finalApiKey, sessionId, setCurrentQueryId);
109109

110-
const formContext = useMemo(() => ({
111-
ticketForm: ticketForm || {},
112-
feedbackForm: feedbackForm || {},
113-
updateTicketForm,
114-
updateFeedbackForm,
115-
resetTicketForm,
116-
resetFeedbackForm
110+
const formContext = useMemo(() => ({
111+
ticketForm: ticketForm || {},
112+
feedbackForm: feedbackForm || {},
113+
updateTicketForm,
114+
updateFeedbackForm,
115+
resetTicketForm,
116+
resetFeedbackForm
117117
}), [ticketForm, feedbackForm, updateTicketForm, updateFeedbackForm, resetTicketForm, resetFeedbackForm]);
118-
118+
119119
const flow = useMemo(() => createBotFlow({
120120
welcomeMessage,
121121
isBotLoggedIn,
@@ -139,7 +139,7 @@ const QABotInternal = React.forwardRef((props, botRef) => {
139139
useUpdateHeader(isBotLoggedIn, containerRef);
140140
useRingEffect(ringEffect, containerRef);
141141
useFocusableSendButton();
142-
useKeyboardNavigation();
142+
useKeyboardNavigation(containerRef);
143143

144144
// Handle tooltip session tracking
145145
useEffect(() => {
@@ -159,8 +159,8 @@ const QABotInternal = React.forwardRef((props, botRef) => {
159159
}, []);
160160

161161
return (
162-
<div
163-
className={`qa-bot ${embedded ? "embedded-qa-bot" : ""}`}
162+
<div
163+
className={`qa-bot ${embedded ? "embedded-qa-bot" : ""}`}
164164
ref={containerRef}
165165
role="region"
166166
aria-label="Ask ACCESS tool"
@@ -180,18 +180,18 @@ const QABotInternal = React.forwardRef((props, botRef) => {
180180
plugins={[HtmlRenderer(), MarkdownRenderer(), InputValidator()]}
181181
/>
182182
{/* Live region for screen reader announcements */}
183-
<div
184-
aria-live="polite"
183+
<div
184+
aria-live="polite"
185185
aria-label="Bot response updates"
186186
className="sr-only"
187187
id="bot-live-region"
188188
/>
189-
189+
190190
{/* Accessibility help text */}
191191
<div id="chat-input-help" className="sr-only">
192192
Type your message and press Enter to send. Use arrow keys to navigate through response options. Press Enter or Space to select an option.
193193
</div>
194-
194+
195195
{/* Keyboard navigation instructions */}
196196
<div id="keyboard-help" className="sr-only">
197197
Available keyboard shortcuts: Arrow keys to navigate options, Enter or Space to select, Tab to move between interactive elements, Escape to close dialogs.

0 commit comments

Comments
 (0)