This commit is contained in:
Yuhong Sun 2024-12-10 15:27:48 -08:00 committed by GitHub
parent 6d6e12119b
commit fe83f676df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -35,6 +35,13 @@ export function SetDefaultModelModal({
const container = containerRef.current;
const message = messageRef.current;
const handleEscape = (e: KeyboardEvent) => {
if (e.key === "Escape") {
onClose();
}
};
window.addEventListener("keydown", handleEscape);
if (container && message) {
const checkScrollable = () => {
if (container.scrollHeight > container.clientHeight) {
@ -45,9 +52,14 @@ export function SetDefaultModelModal({
};
checkScrollable();
window.addEventListener("resize", checkScrollable);
return () => window.removeEventListener("resize", checkScrollable);
return () => {
window.removeEventListener("resize", checkScrollable);
window.removeEventListener("keydown", handleEscape);
};
}
}, []);
return () => window.removeEventListener("keydown", handleEscape);
}, [onClose]);
const defaultModelDestructured = defaultModel
? destructureValue(defaultModel)