Fix composer buttons (#1320)

<!-- Please read
https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before
submitting your pull request -->

### Description

<!-- Please include a summary of the change. Please also include
relevant motivation and context. List any dependencies that are required
for this change. -->

makes them appear when emoji button is disabled and adjusts which ones
are highlighted properly

#### Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

### Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings

### AI disclosure:

- [ ] Partially AI assisted (clarify which code was AI assisted and
briefly explain what it does).
- [ ] Fully AI generated (explain what all the generated code does in
moderate detail).
<!-- Write any explanation required here, but do not generate the
explanation using AI!! You must prove you understand what the code in
this PR does. -->
This commit is contained in:
7w1 authored and GitHub committed 2026-07-24 23:13:45 -05:00
commit 7e58708223
2 files changed
+35 -24

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) =>
+33 -19
View File
@@ -109,6 +109,7 @@ import { loadImageElementFromMediaUrl } from '$utils/dom';
import { safeFile } from '$utils/mimeTypes';
import { fulfilledPromiseSettledResult } from '$utils/common';
import { useSetting } from '$state/hooks/settings';
import type { EditorButtonId } from '$state/settings';
import { settingsAtom } from '$state/settings';
import { matchesShortcut } from '../../keyboard/shortcuts';
import {
@@ -365,6 +366,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 +543,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 +2247,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 +2257,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 +2276,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 +2297,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 +2308,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>
);
@@ -2342,11 +2344,23 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
alignOffset={-44}
position="Top"
align="End"
anchor={
emojiBoardTab === undefined
? undefined
: (emojiBtnRef.current?.getBoundingClientRect() ?? undefined)
}
anchor={(() => {
if (emojiBoardTab === undefined) return undefined;
const buttonRefs: Record<EditorButtonId, RefObject<HTMLButtonElement>> = {
gif: gifBtnRef,
sticker: stickerBtnRef,
emoji: emojiBtnRef,
};
for (let i = editorButtonOrder.length - 1; i >= 0; i--) {
const id = editorButtonOrder[i];
if (!id) continue;
const btnRef = buttonRefs[id];
if (btnRef?.current) {
return btnRef.current.getBoundingClientRect();
}
}
return undefined;
})()}
content={emojiBoard}
>
{triggers}