Skip to content

Comments

OCPBUGS-76558: Fix Add page getting started cards not clickable#16041

Closed
sg00dwin wants to merge 1 commit intoopenshift:mainfrom
sg00dwin:OCPBUGS-76558-getting-started-cards-not-clickable
Closed

OCPBUGS-76558: Fix Add page getting started cards not clickable#16041
sg00dwin wants to merge 1 commit intoopenshift:mainfrom
sg00dwin:OCPBUGS-76558-getting-started-cards-not-clickable

Conversation

@sg00dwin
Copy link
Member

@sg00dwin sg00dwin commented Feb 18, 2026

Summary

Fixes intermittent navigation failures on Add page cards caused by unstable component identity in the Masonry
layout.

Problem

After removing react-measure dependency (PR #14844), cards on the Add page would not navigate when clicked.
The issue was caused by:

  1. Component redefinition - MeasuredItem was defined inside Children.forEach loop, creating new
    component identity on every render
  2. Infinite re-render loop - Unmemoized callbacks caused continuous effect executions
  3. Key inconsistency - Different keys used for React reconciliation vs height tracking

This caused React to constantly unmount/remount DOM nodes, losing click events during transitions.

Solution

  1. Stable component definition - Moved MeasuredItem outside the loop with stable identity
  2. Memoized callbacks - Wrapped setHeight in useCallback to prevent unnecessary re-renders
  3. Consistent key handling - Use effectiveKey throughout for both React keys and height tracking
  4. Ref-based height tracking - Use lastHeightRef instead of closure to avoid stale data

Testing

  • Cards navigate on click (no longer intermittent)
  • No browser console warnings, related to continuous re rendering
  • No DOM flickering
  • Elements can be inspected in DevTools

Related

Assisted by: Claude Code

Summary by CodeRabbit

  • Refactor
    • Improved masonry layout component's height measurement calculations for more stable and consistent item positioning with optimized rendering performance.

@openshift-ci-robot openshift-ci-robot added jira/severity-important Referenced Jira bug's severity is important for the branch this PR is targeting. 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 Feb 18, 2026
@openshift-ci-robot
Copy link
Contributor

@sg00dwin: This pull request references Jira Issue OCPBUGS-76558, 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:

Summary

Fixes intermittent navigation failures on Add page cards caused by unstable component identity in the Masonry
layout.

Problem

After removing react-measure dependency (PR #14844), cards on the Add page would not navigate when clicked.
The issue was caused by:

  1. Component redefinition - MeasuredItem was defined inside Children.forEach loop, creating new
    component identity on every render
  2. Infinite re-render loop - Unmemoized callbacks caused continuous effect executions (300+ warnings/second)
  3. Key inconsistency - Different keys used for React reconciliation vs height tracking

This caused React to constantly unmount/remount DOM nodes, losing click events during transitions.

Solution

  1. Stable component definition - Moved MeasuredItem outside the loop with stable identity
  2. Memoized callbacks - Wrapped setHeight in useCallback to prevent unnecessary re-renders
  3. Consistent key handling - Use effectiveKey throughout for both React keys and height tracking
  4. Ref-based height tracking - Use lastHeightRef instead of closure to avoid stale data

Testing

  • Cards navigate on click (no longer intermittent)
  • No browser console warnings, related to continuous re rendering
  • No DOM flickering
  • Elements can be inspected in DevTools

Related

Assisted by: Claude Code

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.

@sg00dwin
Copy link
Member Author

/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 Feb 18, 2026
@openshift-ci-robot
Copy link
Contributor

@sg00dwin: This pull request references Jira Issue OCPBUGS-76558, 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)

Requesting review from QA contact:
/cc @yapei

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 openshift-ci bot requested a review from yapei February 18, 2026 17:29
@openshift-ci-robot
Copy link
Contributor

@sg00dwin: This pull request references Jira Issue OCPBUGS-76558, which is valid.

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 POST, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @yapei

Details

In response to this:

Summary

Fixes intermittent navigation failures on Add page cards caused by unstable component identity in the Masonry
layout.

Problem

After removing react-measure dependency (PR #14844), cards on the Add page would not navigate when clicked.
The issue was caused by:

  1. Component redefinition - MeasuredItem was defined inside Children.forEach loop, creating new
    component identity on every render
  2. Infinite re-render loop - Unmemoized callbacks caused continuous effect executions (300+ warnings/second)
  3. Key inconsistency - Different keys used for React reconciliation vs height tracking

This caused React to constantly unmount/remount DOM nodes, losing click events during transitions.

Solution

  1. Stable component definition - Moved MeasuredItem outside the loop with stable identity
  2. Memoized callbacks - Wrapped setHeight in useCallback to prevent unnecessary re-renders
  3. Consistent key handling - Use effectiveKey throughout for both React keys and height tracking
  4. Ref-based height tracking - Use lastHeightRef instead of closure to avoid stale data

Testing

  • Cards navigate on click (no longer intermittent)
  • No browser console warnings, related to continuous re rendering
  • No DOM flickering
  • Elements can be inspected in DevTools

Related

Assisted by: Claude Code

Summary by CodeRabbit

  • Refactor
  • Improved masonry layout component's height measurement calculations for more stable and consistent item positioning with optimized rendering performance.

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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

📝 Walkthrough

Walkthrough

The Masonry component refactoring introduces a dedicated MeasuredItem internal component that handles height measurement and reporting via an onMeasure callback. A memoized setHeight function using useCallback updates the heights state, while an effectiveKey derived from item.key and itemIndex maintains consistent height tracking across layout operations. Measured items receive stable keys based on this effectiveKey to ensure proper reconciliation during re-renders, and the grouping logic now references heights via this derived key instead of direct index access.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title references a JIRA issue (OCPBUGS-76558) and describes the main fix (Add page cards not clickable), which aligns with the changeset's core objective of restoring reliable card navigation by stabilizing component identity in the Masonry layout.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

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

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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

🤖 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/packages/dev-console/src/components/add/layout/Masonry.tsx`:
- Around line 17-28: MeasuredItem currently only measures height once (useEffect
with [itemKey, onMeasure]) so late changes (async images, lazy content,
responsive shifts) won't update column balancing; modify MeasuredItem to observe
size changes by attaching a ResizeObserver to measureRef (use the existing
ResizeObserver utility or the pattern from MasonryLayout), compare against
lastHeightRef, and call onMeasure(itemKey, newHeight) whenever height changes;
ensure observer is cleaned up on unmount and that measureRef/null checks are
handled.

Comment on lines +17 to +28
// Stable component definition - prevents unmount/remount cycles
const MeasuredItem: FC<MeasuredItemProps> = ({ item, itemKey, onMeasure }) => {
const measureRef = useRef<HTMLDivElement>(null);
const lastHeightRef = useRef<number>(0);

useEffect(() => {
const newHeight = measureRef.current?.getBoundingClientRect().height;
if (newHeight && lastHeightRef.current !== newHeight) {
lastHeightRef.current = newHeight;
onMeasure(itemKey, newHeight);
}
}, [itemKey, onMeasure]);
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 | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find Masonry usage to assess if children can resize after mount
echo "=== Masonry usages ===" 
rg -n --type=tsx --type=ts '\bMasonry\b' -C 3

echo -e "\n=== ResizeObserver availability ==="
rg -n 'ResizeObserver' -S

Repository: openshift/console

Length of output: 6356


🏁 Script executed:

#!/bin/bash
# Check the actual Masonry.tsx file
echo "=== Masonry.tsx content ==="
cat -n frontend/packages/dev-console/src/components/add/layout/Masonry.tsx | head -60

echo -e "\n=== MasonryLayout.tsx for comparison ==="
cat -n frontend/packages/dev-console/src/components/add/layout/MasonryLayout.tsx | head -60

echo -e "\n=== Check if Masonry is imported/used in MasonryLayout ==="
rg -n 'import.*Masonry' frontend/packages/dev-console/src/components/add/layout/

Repository: openshift/console

Length of output: 5464


Individual item height changes after mount won't update column balancing

MeasuredItem measures height only on mount (dependency array never triggers re-measure since onMeasure is memoized and itemKey is stable). If Add cards can change height after mount—e.g., async images, lazy-loaded content, or responsive resizing within items—column heights become stale and balancing drifts. If cards are guaranteed static, this is fine; otherwise, observe size changes.

🔧 Suggested fix using ResizeObserver
 useEffect(() => {
-  const newHeight = measureRef.current?.getBoundingClientRect().height;
-  if (newHeight && lastHeightRef.current !== newHeight) {
-    lastHeightRef.current = newHeight;
-    onMeasure(itemKey, newHeight);
-  }
+  const element = measureRef.current;
+  if (!element) return;
+
+  const updateHeight = (height: number) => {
+    if (lastHeightRef.current !== height) {
+      lastHeightRef.current = height;
+      onMeasure(itemKey, height);
+    }
+  };
+
+  // Initial measure
+  updateHeight(element.getBoundingClientRect().height);
+
+  const observer = new ResizeObserver((entries) => {
+    const height = entries[0]?.contentRect.height ?? 0;
+    updateHeight(height);
+  });
+  observer.observe(element);
+  return () => observer.disconnect();
 }, [itemKey, onMeasure]);

ResizeObserver is already available in the codebase and used in similar measurement patterns (e.g., MasonryLayout for container resizing). Confirm whether Add items can realistically resize—if so, this is a good safeguard.

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

In `@frontend/packages/dev-console/src/components/add/layout/Masonry.tsx` around
lines 17 - 28, MeasuredItem currently only measures height once (useEffect with
[itemKey, onMeasure]) so late changes (async images, lazy content, responsive
shifts) won't update column balancing; modify MeasuredItem to observe size
changes by attaching a ResizeObserver to measureRef (use the existing
ResizeObserver utility or the pattern from MasonryLayout), compare against
lastHeightRef, and call onMeasure(itemKey, newHeight) whenever height changes;
ensure observer is cleaned up on unmount and that measureRef/null checks are
handled.

@openshift-ci openshift-ci bot added the component/dev-console Related to dev-console label Feb 18, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 18, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sg00dwin
Once this PR has been reviewed and has the lgtm label, please assign vikram-raj for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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
Copy link
Contributor

openshift-ci bot commented Feb 18, 2026

@sg00dwin: 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.

Copy link
Member

@logonoff logonoff left a comment

Choose a reason for hiding this comment

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

Possibly a dupe of #16045?

@openshift-ci-robot
Copy link
Contributor

@sg00dwin: This pull request references Jira Issue OCPBUGS-76558. The bug has been updated to no longer refer to the pull request using the external bug tracker. All external bug links have been closed. The bug has been moved to the NEW state.

Details

In response to this:

Summary

Fixes intermittent navigation failures on Add page cards caused by unstable component identity in the Masonry
layout.

Problem

After removing react-measure dependency (PR #14844), cards on the Add page would not navigate when clicked.
The issue was caused by:

  1. Component redefinition - MeasuredItem was defined inside Children.forEach loop, creating new
    component identity on every render
  2. Infinite re-render loop - Unmemoized callbacks caused continuous effect executions
  3. Key inconsistency - Different keys used for React reconciliation vs height tracking

This caused React to constantly unmount/remount DOM nodes, losing click events during transitions.

Solution

  1. Stable component definition - Moved MeasuredItem outside the loop with stable identity
  2. Memoized callbacks - Wrapped setHeight in useCallback to prevent unnecessary re-renders
  3. Consistent key handling - Use effectiveKey throughout for both React keys and height tracking
  4. Ref-based height tracking - Use lastHeightRef instead of closure to avoid stale data

Testing

  • Cards navigate on click (no longer intermittent)
  • No browser console warnings, related to continuous re rendering
  • No DOM flickering
  • Elements can be inspected in DevTools

Related

Assisted by: Claude Code

Summary by CodeRabbit

  • Refactor
  • Improved masonry layout component's height measurement calculations for more stable and consistent item positioning with optimized rendering performance.

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.

@sg00dwin
Copy link
Member Author

Closing in favor of going with this fix
#16045

@sg00dwin sg00dwin deleted the OCPBUGS-76558-getting-started-cards-not-clickable branch February 19, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/dev-console Related to dev-console jira/severity-important Referenced Jira bug's severity is important for the branch this PR is targeting. 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.

3 participants