Skip to content

Commit 91548d3

Browse files
committed
feat(web): prefer hide-ui over hide-ui=true
1 parent 9f3bc63 commit 91548d3

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

web/src/components/DocumentControlButtons.tsx

+4-6
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,10 @@ export default function DocumentControlButtons(props: Props): JSX.Element {
4141
url = url.replace(props.version, 'latest')
4242
}
4343

44-
if (shareModalHideUi && !url.includes('?hide-ui=true')) {
45-
const urlObject = URL.parse(url)
46-
if (urlObject !== null) {
47-
urlObject.searchParams.set('hide-ui', 'true')
48-
url = urlObject.toString()
49-
}
44+
if (shareModalHideUi) {
45+
const urlObject = new URL(url)
46+
urlObject.search = 'hide-ui'
47+
url = urlObject.toString()
5048
}
5149

5250
return url

web/src/pages/Docs.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default function Docs(): JSX.Element {
2424
const hash = useRef(location.hash)
2525

2626
const [version, setVersion] = useState<string>(params.version ?? 'latest')
27-
const [hideUi, setHideUi] = useState<boolean>(searchParams.get('hide-ui') === 'true')
27+
const [hideUi, setHideUi] = useState<boolean>(searchParams.get('hide-ui') === '' || searchParams.get('hide-ui') === 'true')
2828
const [iframeUpdateTrigger, setIframeUpdateTrigger] = useState<number>(0)
2929

3030
// This provides the url for the iframe.
@@ -99,7 +99,7 @@ export default function Docs(): JSX.Element {
9999
hash: string,
100100
hideUi: boolean
101101
): string => {
102-
return `/${project}/${version}/${encodeURI(page)}${hash}${hideUi ? '?hide-ui=true' : ''}`
102+
return `/${project}/${version}/${encodeURI(page)}${hash}${hideUi ? '?hide-ui' : ''}`
103103
}
104104

105105
const updateUrl = (newVersion: string, hideUi: boolean): void => {
@@ -159,7 +159,7 @@ export default function Docs(): JSX.Element {
159159
const urlVersion = params.version ?? 'latest'
160160
const urlPage = params['*'] ?? ''
161161
const urlHash = location.hash
162-
const urlHideUi = searchParams.get('hide-ui') === 'true'
162+
const urlHideUi = searchParams.get('hide-ui') === '' || searchParams.get('hide-ui') === 'true'
163163

164164
// update the state to the url params on first loadon
165165
if (urlProject !== project.current) {

web/src/pages/IframePageNotFound.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface Props {
1111
}
1212

1313
export default function IframeNotFound(props: Props): JSX.Element {
14-
const link = `/${props.project}/${props.version}${props.hideUi ? '?hide-ui=true' : ''}`
14+
const link = `/${props.project}/${props.version}${props.hideUi ? '?hide-ui' : ''}`
1515

1616
return (
1717
<div className={styles['iframe-page-not-found']}>

0 commit comments

Comments
 (0)