diff --git a/web/src/components/DocumentControlButtons.tsx b/web/src/components/DocumentControlButtons.tsx index 1971b07b..22c1ef9a 100644 --- a/web/src/components/DocumentControlButtons.tsx +++ b/web/src/components/DocumentControlButtons.tsx @@ -41,12 +41,10 @@ export default function DocumentControlButtons(props: Props): JSX.Element { url = url.replace(props.version, 'latest') } - if (shareModalHideUi && !url.includes('?hide-ui=true')) { - const urlObject = URL.parse(url) - if (urlObject !== null) { - urlObject.searchParams.set('hide-ui', 'true') - url = urlObject.toString() - } + if (shareModalHideUi) { + const urlObject = new URL(url) + urlObject.search = 'hide-ui' + url = urlObject.toString() } return url diff --git a/web/src/pages/Docs.tsx b/web/src/pages/Docs.tsx index 3b944cc3..a25ca712 100644 --- a/web/src/pages/Docs.tsx +++ b/web/src/pages/Docs.tsx @@ -24,7 +24,7 @@ export default function Docs(): JSX.Element { const hash = useRef(location.hash) const [version, setVersion] = useState(params.version ?? 'latest') - const [hideUi, setHideUi] = useState(searchParams.get('hide-ui') === 'true') + const [hideUi, setHideUi] = useState(searchParams.get('hide-ui') === '' || searchParams.get('hide-ui') === 'true') const [iframeUpdateTrigger, setIframeUpdateTrigger] = useState(0) // This provides the url for the iframe. @@ -99,7 +99,7 @@ export default function Docs(): JSX.Element { hash: string, hideUi: boolean ): string => { - return `/${project}/${version}/${encodeURI(page)}${hash}${hideUi ? '?hide-ui=true' : ''}` + return `/${project}/${version}/${encodeURI(page)}${hash}${hideUi ? '?hide-ui' : ''}` } const updateUrl = (newVersion: string, hideUi: boolean): void => { @@ -159,7 +159,7 @@ export default function Docs(): JSX.Element { const urlVersion = params.version ?? 'latest' const urlPage = params['*'] ?? '' const urlHash = location.hash - const urlHideUi = searchParams.get('hide-ui') === 'true' + const urlHideUi = searchParams.get('hide-ui') === '' || searchParams.get('hide-ui') === 'true' // update the state to the url params on first loadon if (urlProject !== project.current) { diff --git a/web/src/pages/IframePageNotFound.tsx b/web/src/pages/IframePageNotFound.tsx index df5c05d5..4ea34be4 100644 --- a/web/src/pages/IframePageNotFound.tsx +++ b/web/src/pages/IframePageNotFound.tsx @@ -11,7 +11,7 @@ interface Props { } export default function IframeNotFound(props: Props): JSX.Element { - const link = `/${props.project}/${props.version}${props.hideUi ? '?hide-ui=true' : ''}` + const link = `/${props.project}/${props.version}${props.hideUi ? '?hide-ui' : ''}` return (