Skip to content

OCPBUGS-77204: Override appendTo only if needed#16108

Open
logonoff wants to merge 1 commit intoopenshift:mainfrom
logonoff:OCPBUGS-77204-term
Open

OCPBUGS-77204: Override appendTo only if needed#16108
logonoff wants to merge 1 commit intoopenshift:mainfrom
logonoff:OCPBUGS-77204-term

Conversation

@logonoff
Copy link
Member

@logonoff logonoff commented Mar 4, 2026

Root cause: I dunno

The issue was introduced in 4.20 where we added appendTo to resource-log. This triggers an upstream issue (patternfly/patternfly-react#12255).

Not sure if this 100% fixes it but by removing the appendTo override when not needed, I can no longer get the documentElement crash as before (by going into pod logs, and both rapidly switching tabs and opening dropdowns at the same time)

Summary by CodeRabbit

  • Bug Fixes
    • Improved popper positioning behavior in fullscreen mode. Poppers now correctly anchor to the toolbar element instead of using static positioning, ensuring better visual alignment.

@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Mar 4, 2026
@openshift-ci-robot
Copy link
Contributor

@logonoff: This pull request references Jira Issue OCPBUGS-77204, which is invalid:

  • expected the bug to target the "4.22.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Root cause: I dunno

The issue was introduced in 4.20 where we added appendTo to resource-log. This triggers an upstream issue (patternfly/patternfly-react#12255).

Not sure if this 100% fixes it but by removing the appendTo override when not needed, I can no longer get the documentElement crash as before (by going into pod logs, and both rapidly switching tabs and opening dropdowns at the same time)

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested review from Leo6Leo and rhamilto March 4, 2026 18:36
@openshift-ci openshift-ci bot added the component/core Related to console core functionality label Mar 4, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 4, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: logonoff

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 4, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

📝 Walkthrough

Walkthrough

The resource-log component was updated to improve popper positioning behavior during fullscreen display. A new toolbar identifier was introduced to enable dynamic anchoring of popper elements. The implementation changes the popper append strategy from a static inline placement to conditionally anchoring against the toolbar container when fullscreen mode is active. The Toolbar component now renders with the corresponding id attribute to support this anchor reference mechanism.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly relates to the main change: conditionally applying the appendTo override only when needed in resource-log, rather than unconditionally, which addresses the upstream PatternFly issue and crash described in the PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
frontend/public/components/utils/resource-log.tsx (1)

219-220: Strengthen toolbar ID uniqueness for safer anchoring.

Line 219 uses only resource.metadata.name, which can collide (e.g., same pod name in different namespaces / multiple log viewers). Since Line 417 binds this into DOM id, collisions can make anchor resolution non-deterministic.

Proposed refactor
-  const toolbarId = `resource-log-toolbar-${resource?.metadata?.name || 'unknown'}`;
+  const toolbarId = `resource-log-toolbar-${
+    resource?.metadata?.namespace || 'unknown-ns'
+  }-${resource?.metadata?.name || 'unknown-name'}-${resource?.metadata?.uid || 'unknown-uid'}`;

Also applies to: 417-417

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/public/components/utils/resource-log.tsx` around lines 219 - 220,
The toolbarId constructed from resource?.metadata?.name is not unique enough;
change the construction of toolbarId to include additional stable identifiers
such as resource?.metadata?.namespace and resource?.metadata?.uid (falling back
to namespace or name if uid is missing), sanitize/slugify the concatenated
string to remove invalid DOM id characters, and use that new toolbarId wherever
the DOM id is bound (the existing toolbarId variable and its consumer) so
anchors are deterministic across namespaces and duplicated names.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@frontend/public/components/utils/resource-log.tsx`:
- Around line 277-278: The appendTo callback can return null when
document.getElementById(toolbarId) is not found during rapid transitions; update
the appendTo for the fullscreen path to return a non-null fallback (e.g.,
document.body or a created fallback element) so Popper never receives null.
Specifically modify the appendTo that currently uses () =>
document.getElementById(toolbarId) (and the similar occurrence around the
toolbarId use at the other location) to check for a found element and fallback
to document.body (or a persistent container) before returning.

---

Nitpick comments:
In `@frontend/public/components/utils/resource-log.tsx`:
- Around line 219-220: The toolbarId constructed from resource?.metadata?.name
is not unique enough; change the construction of toolbarId to include additional
stable identifiers such as resource?.metadata?.namespace and
resource?.metadata?.uid (falling back to namespace or name if uid is missing),
sanitize/slugify the concatenated string to remove invalid DOM id characters,
and use that new toolbarId wherever the DOM id is bound (the existing toolbarId
variable and its consumer) so anchors are deterministic across namespaces and
duplicated names.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a04b13a2-1690-45ff-8d55-e02a626685fd

📥 Commits

Reviewing files that changed from the base of the PR and between 78a64e0 and 11704f5.

📒 Files selected for processing (1)
  • frontend/public/components/utils/resource-log.tsx

Comment on lines +277 to 278
appendTo: isFullscreen ? () => document.getElementById(toolbarId) : undefined,
}}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Prevent null popper container in fullscreen append path.

At Line 277 and Line 361, document.getElementById(toolbarId) can return null during rapid unmount/remount transitions. Add a safe fallback container to avoid intermittent crashes.

Proposed fix
+  const getPopperContainer = useCallback(
+    () => document.getElementById(toolbarId) ?? document.body,
+    [toolbarId],
+  );
...
         popperProps={{
-          appendTo: isFullscreen ? () => document.getElementById(toolbarId) : undefined,
+          appendTo: isFullscreen ? getPopperContainer : undefined,
         }}
...
       popperProps={{
-        appendTo: isFullscreen ? () => document.getElementById(toolbarId) : undefined,
+        appendTo: isFullscreen ? getPopperContainer : undefined,
       }}

Also applies to: 361-362

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/public/components/utils/resource-log.tsx` around lines 277 - 278,
The appendTo callback can return null when document.getElementById(toolbarId) is
not found during rapid transitions; update the appendTo for the fullscreen path
to return a non-null fallback (e.g., document.body or a created fallback
element) so Popper never receives null. Specifically modify the appendTo that
currently uses () => document.getElementById(toolbarId) (and the similar
occurrence around the toolbarId use at the other location) to check for a found
element and fallback to document.body (or a persistent container) before
returning.

@logonoff
Copy link
Member Author

logonoff commented Mar 4, 2026

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Mar 4, 2026
@openshift-ci-robot
Copy link
Contributor

@logonoff: This pull request references Jira Issue OCPBUGS-77204, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 5, 2026

@logonoff: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants