@wordpress/components
Version:
UI components for WordPress.
20 lines (19 loc) • 615 B
JavaScript
// packages/components/src/utils/with-ignore-ime-events.ts
function withIgnoreIMEEvents(handler) {
return (event) => {
const {
isComposing
} = "nativeEvent" in event ? event.nativeEvent : event;
if (isComposing || // Workaround for Mac Safari where the final Enter/Backspace of an IME composition
// is `isComposing=false`, even though it's technically still part of the composition.
// These can only be detected by keyCode.
event.keyCode === 229) {
return;
}
handler(event);
};
}
export {
withIgnoreIMEEvents
};
//# sourceMappingURL=with-ignore-ime-events.js.map