Skip to content

fix: disable code wrapping, allow max. 1 open nav#439

Merged
AlessioGr merged 2 commits intomainfrom
fix/docs-styles
Mar 14, 2025
Merged

fix: disable code wrapping, allow max. 1 open nav#439
AlessioGr merged 2 commits intomainfrom
fix/docs-styles

Conversation

@AlessioGr
Copy link
Copy Markdown
Member

  • Disables code wrapping, which can make them very hard to read

Before:
image

After:
image

  • Allows max. 1 nav item open. Having multiple nav groups open makes it difficult to find stuff, and closing them requires manually clicking every open nav group header.

Before:
CleanShot 2025-03-13 at 18 01 12@2x

After:
CleanShot 2025-03-13 at 18 01 22@2x

@AlessioGr AlessioGr merged commit 87db705 into main Mar 14, 2025
1 check passed
@AlessioGr AlessioGr deleted the fix/docs-styles branch March 14, 2025 00:03
Comment on lines +146 to +150
defaultValue={currentTopic}
onValueChange={(value) =>
window.localStorage.setItem(openTopicsLocalStorageKey, JSON.stringify(value))
}
type="multiple"
type="single"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now doesn't allow all sections to be closed. If one is open, it can't be closed.
Additionally, onChange needs to be modified so that localStorage clears up and stores only one section as expanded. Otherwise, when you refresh the page, the expanded section isn't the last one you expanded.

@jmcapra
Copy link
Copy Markdown

jmcapra commented Aug 24, 2025

There is a small bug in the documentation navigation. Unsure if related to this PR, however this is the only discussion I could find on the topic.

If you navigate directly to a page (e.g. via URL or external navigation), the current nav group is highlighted, but not expanded. The expanded state is determined by the last page you clicked on or navigated to via the nav itself, however arriving at a page through other means results in this buggy state.

image

The issue seems to be related to the "openTopicPreferences" state in the DocsNavigation component. Claude Code suggested this fix, however it seems it might defeat the entire purpose of the "preferences" idea. Personally, I'd prefer an accurate nav bar over one that remember what I clicked on at 3am this morning.

// src/components/DocsNavigation/index.tsx:56
useEffect(() => {
    const preference = window.localStorage.getItem(openTopicsLocalStorageKey)
    if (preference) {
      const parsedPreference = JSON.parse(preference)
      // Ensure the current topic is always included in the open topics
      if (!parsedPreference.includes(currentTopic)) {
        const updatedPreference = [...parsedPreference, currentTopic]
        setOpenTopicPreferences(updatedPreference)
        window.localStorage.setItem(openTopicsLocalStorageKey, JSON.stringify(updatedPreference))
      } else {
        setOpenTopicPreferences(parsedPreference)
      }
    } else {
      setOpenTopicPreferences([currentTopic])
    }
  }, [currentTopic])

Linked issue - #477

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants