diff --git a/src/app/components/GifPicker.tsx b/src/app/components/GifPicker.tsx index ac8a4db8a..57ad613cd 100644 --- a/src/app/components/GifPicker.tsx +++ b/src/app/components/GifPicker.tsx @@ -1,9 +1,10 @@ -import React, { useCallback } from 'react'; +import React, { useCallback, useRef, useState } from 'react'; import FocusTrap from 'focus-trap-react'; import { useAtom } from 'jotai'; import { Grid, SearchBar, SearchContext, SearchContextManager } from '@giphy/react-components'; import { IGif } from '@giphy/js-types'; import { Box, color, config } from 'folds'; +import { useElementSizeObserver } from '../hooks/useElementSizeObserver'; import { useSetting } from '../state/hooks/settings'; import { settingsAtom } from '../state/settings'; import { addRecentGif, RecentGif, recentGifsAtom } from '../state/recentGifs'; @@ -146,8 +147,18 @@ function GifPickerInner({ onSelect, requestClose, lotusTerminal }: GifPickerInne const showRecents = recents.length > 0 && !(term ?? '').trim(); + // The container is min(312px, 100vw-16); feed the Grid the live pixel width + // (minus the inner 8px padding on each side) so it doesn't overflow a phone + // narrower than 312px with a fixed 296px grid. + const containerRef = useRef(null); + const [gridWidth, setGridWidth] = useState(PICKER_WIDTH - 16); + useElementSizeObserver( + useCallback(() => containerRef.current, []), + useCallback((w) => setGridWidth(Math.max(1, Math.floor(w) - 16)), []), + ); + return ( - + {lotusTerminal && (
- - setRingtoneVolume(parseInt(e.target.value, 10))} - aria-label="Ringtone volume" - style={{ flex: 1, accentColor: color.Primary.Main }} - /> - - {ringtoneVolume}% - - - } - /> + + + setRingtoneVolume(parseInt(e.target.value, 10))} + aria-label="Ringtone volume" + style={{ flex: 1, accentColor: color.Primary.Main }} + /> + + {ringtoneVolume}% + + {soundboardEnabled && ( - - setSoundboardVolume(parseInt(e.target.value, 10))} - style={{ flexGrow: 1 }} - aria-label="Soundboard volume" - /> - - {soundboardVolume}% - - - } - /> + <> + + + setSoundboardVolume(parseInt(e.target.value, 10))} + style={{ flexGrow: 1 }} + aria-label="Soundboard volume" + /> + + {soundboardVolume}% + + + )} @@ -2454,19 +2456,13 @@ function Messages() { : 'On-device translation isn’t available in this browser. Use a Chromium desktop browser (Chrome/Edge 138+) or the Lotus desktop app.' } after={ - + onChange={(v) => setTranslateTargetLang(v)} + disabled={!translationSupported} + aria-label="Translate messages into" + options={TRANSLATE_TARGET_LANGUAGES.map((l) => ({ value: l.code, label: l.name }))} + /> } /> {translationSupported && (