fix(layout): various fixes on the book and reader styles and layouts, closes #2368 (#2369)

This commit is contained in:
Huang Xin
2025-10-31 02:34:55 +08:00
committed by GitHub
parent 7142874513
commit cdc1950c3a
6 changed files with 43 additions and 10 deletions
@@ -1,4 +1,4 @@
import React, { useCallback, useEffect } from 'react';
import React, { useCallback, useEffect, useRef } from 'react';
import { FaHeadphones } from 'react-icons/fa6';
import { RiArrowLeftSLine, RiArrowRightSLine } from 'react-icons/ri';
import { RiArrowGoBackLine, RiArrowGoForwardLine } from 'react-icons/ri';
@@ -18,7 +18,7 @@ const DesktopFooterBar: React.FC<FooterBarChildProps> = ({
onSpeakText,
}) => {
const _ = useTranslation();
const { getView, getViewState, getViewSettings } = useReaderStore();
const { hoveredBookKey, getView, getViewState, getViewSettings } = useReaderStore();
const view = getView(bookKey);
const viewState = getViewState(bookKey);
const viewSettings = getViewSettings(bookKey);
@@ -27,6 +27,16 @@ const DesktopFooterBar: React.FC<FooterBarChildProps> = ({
progressValid ? progressFraction * 100 : 0,
);
const rangeInputRef = useRef<HTMLInputElement>(null);
useEffect(() => {
if (hoveredBookKey !== bookKey) {
if (rangeInputRef.current && document.activeElement === rangeInputRef.current) {
rangeInputRef.current.blur();
}
}
}, [hoveredBookKey, bookKey]);
useEffect(() => {
if (progressValid) {
// eslint-disable-next-line react-hooks/set-state-in-effect
@@ -93,6 +103,7 @@ const DesktopFooterBar: React.FC<FooterBarChildProps> = ({
</span>
)}
<input
ref={rangeInputRef}
type='range'
className='text-base-content mx-2 min-w-0 flex-1'
min={0}