payloadcms / payloadcms/website

Documentation Navigation preferences bug

Open
#477 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
634
Forks
195
Avg merge
11h 43m
Merged PRs (30d)
17

Description

Possibly related PR - https://github.com/payloadcms/website/pull/439

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])

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/components/DocsNavigation/index.tsx, especially the openTopicPreferences state and its localStorage effect. Reproduce the issue by opening a documentation page directly, then compare the behavior and proposed approach with PR #439. Done means the current navigation group is highlighted and expanded without losing the intended preference behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
nextjs, react, typescript
Domain
documentation, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.