fix composer button behavior

This commit is contained in:
7w1 committed 2026-07-24 23:03:07 -05:00
1 parent 06ce536666
commit ba605fc0ab
2 files changed
+21 -20

No files matched your search

@@ -766,11 +766,8 @@ export function EmojiBoard({
initialFocus: false,
onDeactivate: requestClose,
allowOutsideClick: (e: MouseEvent | TouchEvent) => {
e.preventDefault();
requestClose();
return false;
},
clickOutsideDeactivates: true,
allowOutsideClick: () => true,
isKeyForward: (evt: KeyboardEvent) =>
!editableActiveElement() && isKeyHotkey(['arrowdown', 'arrowright'], evt),
isKeyBackward: (evt: KeyboardEvent) =>
+19 -15
View File
@@ -365,6 +365,8 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
const [pmpPickerEnable] = useSetting(settingsAtom, 'pmpPicker');
const emojiBtnRef = useRef<HTMLButtonElement>(null);
const gifBtnRef = useRef<HTMLButtonElement>(null);
const stickerBtnRef = useRef<HTMLButtonElement>(null);
const micBtnRef = useRef<HTMLButtonElement>(null);
// Preserve stable list keys across metadata/description replacements without
// storing UI-only IDs in the upload draft state.
@@ -540,6 +542,11 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
const [emojiBoardTab, setEmojiBoardTab] = useState<EmojiBoardTab | undefined>(undefined);
// Android back closes the mobile emoji board instead of navigating away.
useDismissOnBack(() => setEmojiBoardTab(undefined), emojiBoardTab !== undefined);
const toggleEmojiBoardTab = useCallback((tab: EmojiBoardTab) => {
setEmojiBoardTab((prev) => (prev === tab ? undefined : tab));
}, []);
const [personaPickerTab, setPersonaPickerTab] = useState<PersonaPickerTab | undefined>(
undefined
);
@@ -2239,15 +2246,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
onCustomEmojiSelect={handleEmoticonSelect}
onStickerSelect={handleStickerSelect}
onGifSelect={handleGifSelect}
requestClose={() => {
setEmojiBoardTab((t) => {
if (t) {
if (!mobileOrTablet()) ReactEditor.focus(editor);
return undefined;
}
return t;
});
}}
requestClose={() => setEmojiBoardTab(undefined)}
/>
);
const triggers = (
@@ -2257,8 +2256,9 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
if (id === 'gif' && editorGifButton) {
button = (
<IconButton
ref={gifBtnRef}
aria-pressed={emojiBoardTab === EmojiBoardTab.Gif}
onClick={() => setEmojiBoardTab(EmojiBoardTab.Gif)}
onClick={() => toggleEmojiBoardTab(EmojiBoardTab.Gif)}
onPointerDown={suppressEditorRefocus}
variant="SurfaceVariant"
size="300"
@@ -2275,8 +2275,9 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
} else if (id === 'sticker' && editorStickerButton) {
button = (
<IconButton
ref={stickerBtnRef}
aria-pressed={emojiBoardTab === EmojiBoardTab.Sticker}
onClick={() => setEmojiBoardTab(EmojiBoardTab.Sticker)}
onClick={() => toggleEmojiBoardTab(EmojiBoardTab.Sticker)}
onPointerDown={suppressEditorRefocus}
variant="SurfaceVariant"
size="300"
@@ -2295,8 +2296,8 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
button = (
<IconButton
ref={emojiBtnRef}
aria-pressed={emojiBoardTab !== undefined}
onClick={() => setEmojiBoardTab(EmojiBoardTab.Emoji)}
aria-pressed={emojiBoardTab === EmojiBoardTab.Emoji}
onClick={() => toggleEmojiBoardTab(EmojiBoardTab.Emoji)}
onPointerDown={suppressEditorRefocus}
variant="SurfaceVariant"
size="300"
@@ -2306,7 +2307,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
aria-label="Open emoji board"
>
{composerIcon(Smiley, {
weight: emojiBoardTab !== undefined ? 'fill' : 'regular',
weight: emojiBoardTab === EmojiBoardTab.Emoji ? 'fill' : 'regular',
})}
</IconButton>
);
@@ -2345,7 +2346,10 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
anchor={
emojiBoardTab === undefined
? undefined
: (emojiBtnRef.current?.getBoundingClientRect() ?? undefined)
: (emojiBtnRef.current?.getBoundingClientRect() ??
gifBtnRef.current?.getBoundingClientRect() ??
stickerBtnRef.current?.getBoundingClientRect() ??
undefined)
}
content={emojiBoard}
>