mirror of
https://github.com/remvze/moodist.git
synced 2025-12-17 08:54:13 +00:00
fix: remove auto focus on load
This commit is contained in:
parent
e490a1da84
commit
3b0c22968e
1 changed files with 14 additions and 7 deletions
|
|
@ -18,18 +18,20 @@ interface SoundsProps {
|
|||
|
||||
export function Sounds({ functional, id, sounds }: SoundsProps) {
|
||||
const [showAll, setShowAll] = useLocalStorage(`${id}-show-more`, false);
|
||||
const [clickedMore, setClickedMore] = useState(false);
|
||||
|
||||
const firstNewSound = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (showAll && clickedMore) {
|
||||
firstNewSound.current?.focus();
|
||||
setClickedMore(false);
|
||||
}
|
||||
}, [showAll, clickedMore]);
|
||||
|
||||
const showMoreButton = useRef<HTMLButtonElement>(null);
|
||||
const [exitComplete, setExitComplete] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (showAll) {
|
||||
firstNewSound.current?.focus();
|
||||
}
|
||||
}, [showAll]);
|
||||
|
||||
const [hiddenSelections, setHiddenSelections] = useState<{
|
||||
[key: string]: boolean;
|
||||
}>({});
|
||||
|
|
@ -54,6 +56,11 @@ export function Sounds({ functional, id, sounds }: SoundsProps) {
|
|||
}));
|
||||
}, []);
|
||||
|
||||
const toggleMore = () => {
|
||||
setShowAll(prev => !prev);
|
||||
setClickedMore(true);
|
||||
};
|
||||
|
||||
const variants = mix(fade(), scale(0.9));
|
||||
|
||||
return (
|
||||
|
|
@ -95,7 +102,7 @@ export function Sounds({ functional, id, sounds }: SoundsProps) {
|
|||
styles.button,
|
||||
hasHiddenSelection && !showAll && styles.active,
|
||||
)}
|
||||
onClick={() => setShowAll(prev => !prev)}
|
||||
onClick={toggleMore}
|
||||
onAnimationComplete={() => {
|
||||
if (!showAll && exitComplete) {
|
||||
setExitComplete(false);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue