Fix emoji picker closing when using pen/touch

This commit is contained in:
Jamie
2025-11-13 11:01:43 -08:00
committed by GitHub
parent 32320a0d2e
commit e6b297da74

View File

@@ -160,6 +160,12 @@ function getSelectedSection(
return EmojiPickerCategory.SmileysAndPeople;
}
function isKeyboardPointerEvent(event: PointerEvent): boolean {
// "" means input source could not be determined (not mouse, pen, or touch)
// https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerType
return event.nativeEvent.pointerType === '';
}
export type FunEmojiSelection = Readonly<{
variantKey: EmojiVariantKey;
}>;
@@ -664,8 +670,7 @@ const Cell = memo(function Cell(props: CellProps): JSX.Element {
variantKey: emojiVariant.key,
};
const shouldClose =
event.nativeEvent.pointerType !== 'mouse' &&
!(event.ctrlKey || event.metaKey);
isKeyboardPointerEvent(event) && !(event.ctrlKey || event.metaKey);
onSelectEmoji(emojiSelection, shouldClose);
},
[