diff --git a/src/components/player/Navigator.tsx b/src/components/player/Navigator.tsx index 20b1a98..dfbcceb 100644 --- a/src/components/player/Navigator.tsx +++ b/src/components/player/Navigator.tsx @@ -9,25 +9,12 @@ export const Navigator = ({ currentPage, numPages, skipToLocation }: { skipToLocation: (location: string | number, shouldPause?: boolean) => void; }) => { const [inputValue, setInputValue] = useState(''); - const [isPopoverOpen, setIsPopoverOpen] = useState(false); const inputRef = useRef(null); useEffect(() => { setInputValue(currentPage.toString()); }, [currentPage]); - // Auto-focus and select input when popover opens - useEffect(() => { - if (isPopoverOpen && inputRef.current) { - // Small delay to ensure the popover is fully rendered - const timer = setTimeout(() => { - inputRef.current?.focus(); - inputRef.current?.select(); - }, 50); - return () => clearTimeout(timer); - } - }, [isPopoverOpen]); - const handleInputChange = (e: React.ChangeEvent) => { // Only allow numbers const value = e.target.value.replace(/[^0-9]/g, ''); @@ -56,6 +43,11 @@ export const Navigator = ({ currentPage, numPages, skipToLocation }: { const handlePopoverOpen = () => { setInputValue(''); // Clear input when popup opens + // Auto-focus and select input shortly after opening + setTimeout(() => { + inputRef.current?.focus(); + inputRef.current?.select(); + }, 50); }; return ( @@ -73,44 +65,34 @@ export const Navigator = ({ currentPage, numPages, skipToLocation }: { {/* Page number popup */} - - {({ open }) => { - if (open !== isPopoverOpen) { - setIsPopoverOpen(open); - } - - return ( - <> - -

- {currentPage} / {numPages || 1} -

-
- -
-
Go to page
- -
of {numPages || 1}
-
-
- - ); - }} + + +

+ {currentPage} / {numPages || 1} +

+
+ +
+
Go to page
+ +
of {numPages || 1}
+
+
{/* Page forward */} @@ -126,4 +108,4 @@ export const Navigator = ({ currentPage, numPages, skipToLocation }: { ); -} \ No newline at end of file +}