diff --git a/src/components/player/Navigator.tsx b/src/components/player/Navigator.tsx index 6e83a05..360498d 100644 --- a/src/components/player/Navigator.tsx +++ b/src/components/player/Navigator.tsx @@ -9,12 +9,25 @@ 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, ''); @@ -61,33 +74,43 @@ export const Navigator = ({ currentPage, numPages, skipToLocation }: { {/* Page number popup */} - -

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

-
- -
-
Go to page
- -
of {numPages || 1}
-
-
+ {({ open }) => { + if (open !== isPopoverOpen) { + setIsPopoverOpen(open); + } + + return ( + <> + +

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

+
+ +
+
Go to page
+ +
of {numPages || 1}
+
+
+ + ); + }}
{/* Page forward */}