Skip to content

Commit 94dee64

Browse files
authored
Merge branch 'main' into patricia/updateProjectByYaml
2 parents b940ad3 + bf47a97 commit 94dee64

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/js/chatbot.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,13 @@
6464

6565
// Function to force positioning
6666
function forceChatbotPosition() {
67-
// Handle all possible widget states
68-
const allWidgets = document.querySelectorAll('.dify-chatbot-widget, [class*="dify"], [id*="dify"]');
69-
const allWindows = document.querySelectorAll('#dify-chatbot-bubble-window, [class*="chat"], [class*="window"]');
67+
// Only target specific chatbot elements with very specific selectors
68+
const chatbotWidgets = document.querySelectorAll('.dify-chatbot-widget, #dify-chatbot-widget');
69+
const chatbotWindows = document.querySelectorAll('#dify-chatbot-bubble-window, .dify-chatbot-bubble-window');
70+
const chatbotButtons = document.querySelectorAll('#dify-chatbot-bubble-button, .dify-chatbot-bubble-button');
7071

71-
// Position all widget containers
72-
allWidgets.forEach(widget => {
72+
// Position chatbot widget containers only
73+
chatbotWidgets.forEach(widget => {
7374
widget.style.position = 'fixed';
7475
widget.style.bottom = '0';
7576
widget.style.right = '0';
@@ -80,8 +81,8 @@
8081
widget.style.transform = 'none';
8182
});
8283

83-
// Position all window elements
84-
allWindows.forEach(window => {
84+
// Position chatbot window elements only
85+
chatbotWindows.forEach(window => {
8586
window.style.position = 'fixed';
8687
window.style.bottom = '0';
8788
window.style.right = '0';
@@ -91,9 +92,9 @@
9192
window.style.transform = 'none';
9293
});
9394

94-
// Also handle any iframe that might be created
95-
const iframes = document.querySelectorAll('iframe[src*="dify"], iframe[src*="udify"]');
96-
iframes.forEach(iframe => {
95+
// Handle chatbot iframes specifically
96+
const chatbotIframes = document.querySelectorAll('iframe[src*="dify"], iframe[src*="udify"]');
97+
chatbotIframes.forEach(iframe => {
9798
iframe.style.position = 'fixed';
9899
iframe.style.bottom = '0';
99100
iframe.style.right = '0';
@@ -103,9 +104,9 @@
103104
iframe.style.transform = 'none';
104105
});
105106

106-
// Special handling for expanded state - target any element that might be the expanded window
107-
const expandedElements = document.querySelectorAll('[data-state="expanded"], [class*="expanded"], [style*="position: fixed"]');
108-
expandedElements.forEach(element => {
107+
// Only target expanded chatbot elements
108+
const expandedChatbotElements = document.querySelectorAll('.dify-chatbot-widget[data-state="expanded"], .dify-chatbot-widget .expanded');
109+
expandedChatbotElements.forEach(element => {
109110
element.style.position = 'fixed';
110111
element.style.bottom = '0';
111112
element.style.right = '0';
@@ -116,9 +117,9 @@
116117
element.style.zIndex = '1000';
117118
});
118119

119-
// Also force any element with a high z-index to stay at bottom
120-
const highZIndexElements = document.querySelectorAll('[style*="z-index: 999"], [style*="z-index: 1000"], [style*="z-index: 1001"]');
121-
highZIndexElements.forEach(element => {
120+
// Only force positioning on chatbot elements with high z-index
121+
const highZIndexChatbotElements = document.querySelectorAll('.dify-chatbot-widget[style*="z-index: 999"], .dify-chatbot-widget[style*="z-index: 1000"], .dify-chatbot-widget[style*="z-index: 1001"]');
122+
highZIndexChatbotElements.forEach(element => {
122123
if (element.style.position === 'fixed') {
123124
element.style.bottom = '0';
124125
element.style.right = '0';
@@ -127,9 +128,9 @@
127128
}
128129
});
129130

130-
// Make background elements more translucent to show rounded corners
131-
const allElements = document.querySelectorAll('.dify-chatbot-widget *');
132-
allElements.forEach(element => {
131+
// Make chatbot background elements more translucent to show rounded corners
132+
const chatbotElements = document.querySelectorAll('.dify-chatbot-widget *');
133+
chatbotElements.forEach(element => {
133134
const computedStyle = window.getComputedStyle(element);
134135
// Look for dark backgrounds that are likely the main content area
135136
if (computedStyle.backgroundColor &&
@@ -147,8 +148,7 @@
147148
});
148149

149150
// Ensure chat button is circular
150-
const chatButtons = document.querySelectorAll('[id*="bubble-button"], [class*="bubble-button"]');
151-
chatButtons.forEach(button => {
151+
chatbotButtons.forEach(button => {
152152
button.style.borderRadius = '50%';
153153
button.style.width = '60px';
154154
button.style.height = '60px';

0 commit comments

Comments
 (0)