Documentation Navigation preferences bug

未关闭
#477 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞

调研方向

从 src/components/DocsNavigation/index.tsx 开始,重点查看 openTopicPreferences 状态及其 localStorage effect。直接打开一个文档页面来复现问题,然后将行为和提议的处理方式与 PR #439 进行比较。当当前导航组被高亮并展开,且不会丢失预期的 preference 行为时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

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])
主要语言
TypeScript
星标
643
派生
193
平均合并
17 小时 9 分钟
30 天内合并 PR
3

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

payloadcms/website 的其他 Issue

查看 payloadcms/website 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。