mirror of
https://github.com/remvze/moodist.git
synced 2025-12-17 17:04:15 +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) {
|
export function Sounds({ functional, id, sounds }: SoundsProps) {
|
||||||
const [showAll, setShowAll] = useLocalStorage(`${id}-show-more`, false);
|
const [showAll, setShowAll] = useLocalStorage(`${id}-show-more`, false);
|
||||||
|
const [clickedMore, setClickedMore] = useState(false);
|
||||||
|
|
||||||
const firstNewSound = useRef<HTMLDivElement>(null);
|
const firstNewSound = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (showAll && clickedMore) {
|
||||||
|
firstNewSound.current?.focus();
|
||||||
|
setClickedMore(false);
|
||||||
|
}
|
||||||
|
}, [showAll, clickedMore]);
|
||||||
|
|
||||||
const showMoreButton = useRef<HTMLButtonElement>(null);
|
const showMoreButton = useRef<HTMLButtonElement>(null);
|
||||||
const [exitComplete, setExitComplete] = useState(false);
|
const [exitComplete, setExitComplete] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (showAll) {
|
|
||||||
firstNewSound.current?.focus();
|
|
||||||
}
|
|
||||||
}, [showAll]);
|
|
||||||
|
|
||||||
const [hiddenSelections, setHiddenSelections] = useState<{
|
const [hiddenSelections, setHiddenSelections] = useState<{
|
||||||
[key: string]: boolean;
|
[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));
|
const variants = mix(fade(), scale(0.9));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -95,7 +102,7 @@ export function Sounds({ functional, id, sounds }: SoundsProps) {
|
||||||
styles.button,
|
styles.button,
|
||||||
hasHiddenSelection && !showAll && styles.active,
|
hasHiddenSelection && !showAll && styles.active,
|
||||||
)}
|
)}
|
||||||
onClick={() => setShowAll(prev => !prev)}
|
onClick={toggleMore}
|
||||||
onAnimationComplete={() => {
|
onAnimationComplete={() => {
|
||||||
if (!showAll && exitComplete) {
|
if (!showAll && exitComplete) {
|
||||||
setExitComplete(false);
|
setExitComplete(false);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue