Skip to content

Commit a43d4e6

Browse files
[chat]Fix chatbot open state flaky (#10900)
* Fix chatbot open state flaky Signed-off-by: Lin Wang <[email protected]> * Changeset file for PR #10900 created/updated --------- Signed-off-by: Lin Wang <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
1 parent e37a40a commit a43d4e6

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

changelogs/fragments/10900.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fix:
2+
- Fix chatbot open state flaky ([#10900](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/10900))

src/plugins/chat/public/components/chat_header_button.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,17 @@ export const ChatHeaderButton = React.forwardRef<ChatHeaderButtonInstance, ChatH
169169
});
170170

171171
useEffectOnce(() => {
172-
if (isOpen) {
173-
openSidecar();
172+
if (!isOpen) {
173+
return;
174174
}
175+
176+
const rafId = window.requestAnimationFrame(() => {
177+
openSidecar();
178+
});
179+
180+
return () => {
181+
window.cancelAnimationFrame(rafId);
182+
};
175183
});
176184

177185
return (

0 commit comments

Comments
 (0)