mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
fix(modal): input carry over with IMEs in modal forms (#2709)
* fix(modal): prevent IME input carryover in form fields when tabbing * chore: add changeset * chore: chain default onKeyDown
This commit is contained in:
parent
2829d4afae
commit
eb11a7731a
5
.changeset/old-cameras-sip.md
Normal file
5
.changeset/old-cameras-sip.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@nextui-org/modal": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Prevent IME input carryover in form fields when tabbing
|
||||||
@ -9,8 +9,9 @@ import {CloseIcon} from "@nextui-org/shared-icons";
|
|||||||
import {RemoveScroll} from "react-remove-scroll";
|
import {RemoveScroll} from "react-remove-scroll";
|
||||||
import {domAnimation, LazyMotion, m} from "framer-motion";
|
import {domAnimation, LazyMotion, m} from "framer-motion";
|
||||||
import {useDialog} from "@react-aria/dialog";
|
import {useDialog} from "@react-aria/dialog";
|
||||||
import {mergeProps} from "@react-aria/utils";
|
import {chain, mergeProps} from "@react-aria/utils";
|
||||||
import {HTMLNextUIProps} from "@nextui-org/system";
|
import {HTMLNextUIProps} from "@nextui-org/system";
|
||||||
|
import {KeyboardEvent} from "react";
|
||||||
|
|
||||||
import {useModalContext} from "./modal-context";
|
import {useModalContext} from "./modal-context";
|
||||||
import {scaleInOut} from "./modal-transition";
|
import {scaleInOut} from "./modal-transition";
|
||||||
@ -59,8 +60,17 @@ const ModalContent = forwardRef<"div", ModalContentProps, KeysToOmit>((props, _)
|
|||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Handle Tab key during IME composition to prevent input carryover
|
||||||
|
const onKeyDown = useCallback((e: KeyboardEvent) => {
|
||||||
|
if (e.key === "Tab" && e.nativeEvent.isComposing) {
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const contentProps = getDialogProps(mergeProps(dialogProps, otherProps));
|
||||||
const content = (
|
const content = (
|
||||||
<Component {...getDialogProps(mergeProps(dialogProps, otherProps))}>
|
<Component {...contentProps} onKeyDown={chain(contentProps.onKeyDown, onKeyDown)}>
|
||||||
<DismissButton onDismiss={onClose} />
|
<DismissButton onDismiss={onClose} />
|
||||||
{!hideCloseButton && closeButtonContent}
|
{!hideCloseButton && closeButtonContent}
|
||||||
{typeof children === "function" ? children(onClose) : children}
|
{typeof children === "function" ? children(onClose) : children}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user