LogViewer does not initialize styles correctly when its container is hidden on first render (e.g. within the TabContent for a tab that is not initially selected)
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- react, typescript
- 领域
- frontend
调研方向
Start in packages/module/src/LogViewer/LogViewer.tsx, especially createList around the containerRef.current.clientHeight and clientWidth usage. Reproduce the problem with the docs example by initially hiding the LogViewer wrapper, then verify that the list receives correct dimensions when the wrapper becomes visible without a window resize.
由索引模型根据 Issue 内容生成。
描述
Found while investigating a bug that came up in https://github.com/opendatahub-io/odh-dashboard/pull/2184#discussion_r1399121417 . See related Slack discussion here (Red Hat internal).
We have a set of Tabs with TabContent components. They are rendered the standard way, where all TabContents are rendered regardless of which is active and the non-active tabs get a hidden attribute in the DOM.
One of the tabs which is not the default (its first render gets that hidden attribute) contains a LogViewer. When we switch to the Logs tab and the LogViewer's container becomes visible, the LogViewer's contents appear empty until something else triggers a re-render (such as resizing the window). However, if we change the code so that the Logs tab is the default tab (the LogViewer's first render is in a container that is not hidden), it works as expected.
This appears to be happening because of the way containerRef.current.clientHeight and .clientWidth are used in the createList function here. clientHeight and clientWidth resolve to 0 for hidden elements, so the List gets rendered with 0 height and 0 width. The container changing from hidden to non-hidden does not trigger a re-render in the LogViewer, so the List only gets its height and width set correctly when createList is called again after something else triggers a re-render.
One possible solution to this would be to add some kind of listener or observer that can detect that the containerRef.current element has become visible and have it trigger a re-render similarly to how resizing the window does. This could be done with an IntersectionObserver as described in this blog post.
I was able to reproduce the bug in the docs example here by opening the source of the basic example and editing it to have an additional "hidden" checkbox which defaults to true and applies a hidden attribute on a <div> wrapping the LogViewer. I would link a CodeSandbox showing this but it appears the sandbox generator on the site is broken (at least for this example). Adding an IntersectionObserver in the console while reproducing it in this way, I can detect that visibility changing.
Jira Issue: PF-2013
- 主要语言
- TypeScript
- 星标
- 34
- 派生
- 19
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
patternfly/react-log-viewer 的其他 Issue
-
Search within Log viewer can cause the parent container to shift and break the layout, when embedded in a scrollable parent可能已有人在做 @fao89 于 137 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 67/100
patternfly/react-log-viewer#106 ·
-
难度 3/5 1-2 天 新手友好度 45/100
patternfly/react-log-viewer#101 ·
-
难度 3/5 1-2 天 新手友好度 25/100
patternfly/react-log-viewer#98 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 25/100
patternfly/react-log-viewer#95 · 2 条评论 ·
-
难度 3/5 1-2 天 新手友好度 35/100
patternfly/react-log-viewer#91 · 1 条评论 ·
查看 patternfly/react-log-viewer 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 85/100
-
area:cowork area:desktop documentation enhancement platform:macos
难度 2/5 1-3 小时 新手友好度 68/100
anthropics/claude-code#101720 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
apache/rocketmq-dashboard#6610 ·
维护者通常 3 天内回复
-
Add: MS NOW未关闭check:passed streams:add
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
Global update drops overrideAccess, so Local API updateGlobal fails filterOptions validation (3.90 regression)可能已有人在做 @PINYOPATTANAWASANPORN 今天认领。 未关闭area: core Bug
难度 2/5 1-3 小时 新手友好度 76/100
payloadcms/payload#18674 · 1 条评论 ·
维护者通常 1 天内回复