Skip to content

Commit ec0e49c

Browse files
fix(docs): update VariantItem link implementation and separate CLI version docs Closes npm/cli#8414 (#1659)
<!-- What / Why --> <!-- Describe the request in detail. What it does and why it's being changed. --> ## Description This PR addresses [npm/cli#8414](npm/cli#8414), which reports that switching versions using the CLI version dropdown does not properly update the displayed documentation. ### Changes - **Refactored `VariantItem` component**: These changes ensure that when users switch CLI versions from the dropdown, the documentation updates correctly to display the appropriate content for each version. --- ## Updated https://github.com/user-attachments/assets/8668e308-ac8d-4f09-b6f4-0ddafa67d317 ## References <!-- Examples: Related to #0 Depends on #0 Blocked by #0 Fixes #0 Closes #0 --> Closes npm/cli#8414
1 parent d73a155 commit ec0e49c

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/components/variant-select.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ const StyledOverlay = styled(ActionMenu.Overlay)`
1414
box-shadow: var(--shadow-resting-medium, 0 3px 6px rgba(140, 149, 159, 0.15));
1515
`
1616

17-
const VariantItem = ({title, shortName, url, active}) => (
18-
<ActionList.Item as={LinkNoUnderline} to={url} state={{scrollUpdate: false}} id={shortName} active={active}>
19-
{title}
20-
</ActionList.Item>
21-
)
17+
const VariantItem = ({title, shortName, url, active}) => {
18+
return (
19+
<ActionList.Item state={{scrollUpdate: false}} id={shortName} active={active}>
20+
<LinkNoUnderline to={url}>{title}</LinkNoUnderline>
21+
</ActionList.Item>
22+
)
23+
}
2224

2325
const useVariantFocus = () => {
2426
const locationChange = useLocationChange()
@@ -37,6 +39,13 @@ const VariantMenu = ({title, latest, current, prerelease, legacy}) => {
3739
const [open, setOpen] = React.useState(false)
3840
const anchorRef = useVariantFocus()
3941
const labelId = 'label-versions-list-item'
42+
const locationChange = useLocationChange()
43+
44+
React.useEffect(() => {
45+
if (locationChange.change && getNav.didVariantChange(locationChange.previous, locationChange.current)) {
46+
setOpen(false)
47+
}
48+
}, [locationChange.change, locationChange.current, locationChange.previous])
4049

4150
return (
4251
<>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy