Skip to content

Commit 00d9afc

Browse files
authored
Merge pull request #46 from necyberteam/embedded-fix
prevent embedded bot from breaking page
2 parents 325ba02 + 9045e9b commit 00d9afc

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
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.

src/hooks/useChatBotSettings.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ const useChatBotSettings = ({
5555
chatWindow: {
5656
defaultOpen: embedded ? true : defaultOpen || false,
5757
},
58+
device: {
59+
desktopEnabled: true,
60+
mobileEnabled: true,
61+
applyMobileOptimizations: false
62+
},
5863
chatInput: {
5964
enabledPlaceholderText: 'Type your question here...',
6065
disabledPlaceholderText: '',

src/hooks/useKeyboardNavigation.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,9 @@ const useKeyboardNavigation = () => {
293293

294294
if (!chatWindow) return;
295295

296+
// Check if this is an embedded bot to prevent auto-scroll
297+
const isEmbeddedBot = chatWindow.closest('.embedded-qa-bot') !== null;
298+
296299
// Get all messages to ensure we only focus options in the most recent message
297300
const allMessages = Array.from(chatWindow.querySelectorAll('.rcb-message-container, .rcb-bot-message-container, .rcb-user-message-container'))
298301
.filter(el => el.offsetParent !== null);
@@ -358,9 +361,9 @@ const useKeyboardNavigation = () => {
358361
checkboxContainer.insertBefore(hintElement, checkboxContainer.firstChild);
359362
}
360363

361-
// Focus first element
364+
// Focus first element (skip for embedded bots to prevent auto-scroll)
362365
setTimeout(() => {
363-
if (allElements[0] && allElements[0].offsetParent !== null) {
366+
if (allElements[0] && allElements[0].offsetParent !== null && !isEmbeddedBot) {
364367
allElements[0].focus();
365368
}
366369
}, 150);
@@ -411,9 +414,9 @@ const useKeyboardNavigation = () => {
411414
}
412415
}
413416

414-
// Focus first option after a short delay to allow rendering
417+
// Focus first option after a short delay to allow rendering (skip for embedded bots to prevent auto-scroll)
415418
setTimeout(() => {
416-
if (options[0] && options[0].offsetParent !== null) {
419+
if (options[0] && options[0].offsetParent !== null && !isEmbeddedBot) {
417420
options[0].focus();
418421
if (options.length > 1) {
419422
announceToScreenReader(`${options.length} options available. Use arrow keys to navigate.`);

0 commit comments

Comments
 (0)