Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix footnotes and overflow #1940

Merged
merged 2 commits into from
Mar 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions components/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,13 @@ export function SearchText ({ text }) {

// this is one of the slowest components to render
export default memo(function Text ({ rel = UNKNOWN_LINK_REL, imgproxyUrls, children, tab, itemId, outlawed, topLevel }) {
// would the text overflow on the current screen size?
const [overflowing, setOverflowing] = useState(false)
const router = useRouter()
// should we show the full text?
const [show, setShow] = useState(false)
const containerRef = useRef(null)

const router = useRouter()
const [mathJaxPlugin, setMathJaxPlugin] = useState(null)

// we only need mathjax if there's math content between $$ tags
Expand All @@ -69,9 +72,9 @@ export default memo(function Text ({ rel = UNKNOWN_LINK_REL, imgproxyUrls, child

// if we are navigating to a hash, show the full text
useEffect(() => {
setShow(router.asPath.includes('#') && !router.asPath.includes('#itemfn-'))
setShow(router.asPath.includes('#'))
const handleRouteChange = (url, { shallow }) => {
setShow(url.includes('#') && !url.includes('#itemfn-'))
setShow(url.includes('#'))
}

router.events.on('hashChangeStart', handleRouteChange)
Expand Down