Skip to content

Conversation

@fallmo
Copy link
Contributor

@fallmo fallmo commented Jan 4, 2026

Changes:

Summary by CodeRabbit

  • New Features

    • Login page accepts extended brand image properties for finer control (src, alt, class, aria attributes) and shows the brand only when an image source or image props are provided. When both are supplied, explicit image props take precedence.
  • Tests

    • Added tests covering brand rendering presence, attribute handling, and precedence.
  • Documentation

    • Updated example docs to demonstrate the new brand image properties and usage.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 4, 2026

Walkthrough

LoginPage now accepts an optional brandImgProps?: BrandProps, forwards it to Brand, and renders Brand only when brandImgSrc or brandImgProps is provided. When both are present, brandImgProps.src takes precedence.

Changes

Cohort / File(s) Summary
LoginPage component
packages/react-core/src/components/LoginPage/LoginPage.tsx
Import BrandProps; add brandImgProps?: BrandProps to LoginPageProps; include brandImgProps in props; conditionally render <Brand src={brandImgSrc} alt={brandImgAlt} {...brandImgProps} /> only when brandImgSrc or brandImgProps exists (brandImgProps.src wins when provided).
LoginPage tests
packages/react-core/src/components/LoginPage/__tests__/LoginPage.test.tsx
Add tests for conditional Brand rendering: absent when neither brandImgSrc nor brandImgProps.src provided; present with brandImgSrc; present with brandImgProps (covers src, alt, aria-label, class); brandImgProps.src overrides brandImgSrc.
Examples / Docs
packages/react-core/src/components/LoginPage/examples/LoginPageBasic.tsx, packages/react-core/src/components/LoginPage/examples/LoginPage.md
Example updated to use brandImgProps instead of separate brandImgSrc/brandImgAlt; docs note brandImgProps usage and precedence over brandImgSrc.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • thatblindgeye
  • nicolethoen
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: enabling brand props passthrough and making the brand optional when props are not provided.
Linked Issues check ✅ Passed The PR successfully addresses both linked issues: #11970 (brand props passthrough via brandImgProps) and #11984 (conditional Brand rendering when props are omitted).
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issues: LoginPage component enhancement, tests for new functionality, and documentation updates are all in scope.
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 docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link

@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

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bc46a52 and 9059633.

📒 Files selected for processing (1)
  • packages/react-core/src/components/LoginPage/LoginPage.tsx
🧰 Additional context used
🧬 Code graph analysis (1)
packages/react-core/src/components/LoginPage/LoginPage.tsx (1)
packages/react-core/src/components/Brand/Brand.tsx (2)
  • BrandProps (7-35)
  • Brand (37-82)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build
  • GitHub Check: Build, test & deploy
🔇 Additional comments (3)
packages/react-core/src/components/LoginPage/LoginPage.tsx (3)

5-5: LGTM!

The BrandProps import is correctly added and necessary for the new brandImgProps prop type definition.


24-25: LGTM!

The new optional brandImgProps prop correctly enables consumers to pass additional Brand properties (e.g., width, height) through the LoginPage component, addressing issue #11970.


55-55: LGTM!

The prop destructuring correctly includes the new brandImgProps parameter.

@patternfly-build
Copy link
Collaborator

patternfly-build commented Jan 4, 2026

… without props

Signed-off-by: Mohamed Fall <ps.hackmaster@gmail.com>
Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

LGTM! Similar to a comment I left on your Tabs PR, but would you feel comfortable adding some unit tests for these changes?

@fallmo
Copy link
Contributor Author

fallmo commented Jan 9, 2026

LGTM! Similar to a comment I left on your Tabs PR, but would you feel comfortable adding some unit tests for these changes?

Yes, certainly

@nicolethoen nicolethoen self-requested a review January 9, 2026 21:33
Signed-off-by: Mohamed Fall <ps.hackmaster@gmail.com>
Copy link

@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

🤖 Fix all issues with AI agents
In @packages/react-core/src/components/LoginPage/__tests__/LoginPage.test.tsx:
- Around line 40-45: The test for LoginPage's brandImgProps only checks src/alt
but must verify passthrough of additional attributes; update the test that calls
LoginPage with brandImgProps including extra fields (e.g., width, height,
className, data-*), render the component, then assert those attributes are
applied to the Brand image element (by querying the Brand/img and checking
getAttribute or classList) or include them in the snapshot to confirm forwarding
from the brandImgProps to the Brand component.
🧹 Nitpick comments (3)
packages/react-core/src/components/LoginPage/__tests__/LoginPage.test.tsx (3)

30-33: Consider adding explicit assertions alongside snapshots.

While snapshot testing is valid, adding an explicit query for the Brand component (or its underlying img element) would make the test intent clearer and provide more informative failure messages.

📋 Suggested enhancement
 test('brand is absent without brandImgSrc and brandImgProps.src', () => {
-  const { asFragment } = render(<LoginPage loginTitle="Log into your account" />);
+  const { asFragment, container } = render(<LoginPage loginTitle="Log into your account" />);
+  expect(container.querySelector('img[class*="pf-v6-c-brand"]')).toBeNull();
   expect(asFragment()).toMatchSnapshot();
 });

35-38: Consider adding explicit assertions alongside snapshots.

Similar to the previous test, adding an explicit assertion that the Brand/img element exists would improve test clarity.

📋 Suggested enhancement
 test('brand is present with brandImgSrc prop', () => {
-  const { asFragment } = render(<LoginPage brandImgSrc="Brand src" loginTitle="Log into your account" />);
+  const { asFragment, container } = render(<LoginPage brandImgSrc="Brand src" loginTitle="Log into your account" />);
+  const brandImg = container.querySelector('img[class*="pf-v6-c-brand"]');
+  expect(brandImg).toBeInTheDocument();
+  expect(brandImg).toHaveAttribute('src', 'Brand src');
   expect(asFragment()).toMatchSnapshot();
 });

30-45: Consider testing the edge case when both brandImgSrc and brandImgProps.src are provided.

The implementation spreads brandImgProps after setting src and alt, meaning brandImgProps values should override. Adding a test for this scenario would document the expected precedence behavior and prevent regressions.

📋 Suggested edge case test
test('brandImgProps.src overrides brandImgSrc when both provided', () => {
  const { container } = render(
    <LoginPage
      brandImgSrc="fallback.png"
      brandImgProps={{ src: 'primary.png', alt: 'Primary logo' }}
      loginTitle="Log into your account"
    />
  );
  const brandImg = container.querySelector('img[class*="pf-v6-c-brand"]');
  expect(brandImg).toHaveAttribute('src', 'primary.png');
  expect(brandImg).toHaveAttribute('alt', 'Primary logo');
});
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4ebbbdb and 9df125d.

⛔ Files ignored due to path filters (1)
  • packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginPage.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (1)
  • packages/react-core/src/components/LoginPage/__tests__/LoginPage.test.tsx
🧰 Additional context used
🧬 Code graph analysis (1)
packages/react-core/src/components/LoginPage/__tests__/LoginPage.test.tsx (2)
packages/react-integration/demo-app-ts/src/components/demos/LoginPageDemo/LoginPageDemo.tsx (1)
  • render (59-164)
packages/react-core/src/components/LoginPage/LoginPage.tsx (1)
  • LoginPage (50-99)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build, test & deploy
  • GitHub Check: Build

…ame attributes

Signed-off-by: Mohamed Fall <ps.hackmaster@gmail.com>
Copy link

@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: 0

🧹 Nitpick comments (2)
packages/react-core/src/components/LoginPage/__tests__/LoginPage.test.tsx (2)

30-38: Consider asserting Brand presence/absence directly instead of snapshots. Snapshots here can become noisy when unrelated markup changes.

Possible refactor
 test('brand is absent without brandImgSrc and brandImgProps.src', () => {
-  const { asFragment } = render(<LoginPage loginTitle="Log into your account" />);
-  expect(asFragment()).toMatchSnapshot();
+  render(<LoginPage loginTitle="Log into your account" />);
+  expect(screen.queryByRole('img')).not.toBeInTheDocument();
 });

 test('brand is present with brandImgSrc prop', () => {
-  const { asFragment } = render(<LoginPage brandImgSrc="Brand src" loginTitle="Log into your account" />);
-  expect(asFragment()).toMatchSnapshot();
+  render(<LoginPage brandImgSrc="Brand src" loginTitle="Log into your account" />);
+  expect(screen.getByRole('img')).toHaveAttribute('src', 'Brand src');
 });

54-65: Good precedence test; consider adding a guard for “brandImgProps without src” to prevent empty-src regressions. E.g., pass { className: 'x' } only and assert Brand is not rendered.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9df125d and 94a2c42.

⛔ Files ignored due to path filters (1)
  • packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginPage.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (1)
  • packages/react-core/src/components/LoginPage/__tests__/LoginPage.test.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build
  • GitHub Check: Build, test & deploy
🔇 Additional comments (2)
packages/react-core/src/components/LoginPage/__tests__/LoginPage.test.tsx (2)

2-2: Good switch to screen for DOM assertions (more idiomatic RTL).


40-52: Nice coverage of brandImgProps passthrough (aria-label + className) with concrete assertions.

…d customization

Signed-off-by: Mohamed Fall <ps.hackmaster@gmail.com>
Copy link

@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: 0

🧹 Nitpick comments (1)
packages/react-core/src/components/LoginPage/examples/LoginPageBasic.tsx (1)

114-127: Example demonstrates new feature correctly.

The use of brandImgProps with src, alt, and className effectively showcases the new capability for consumers to customize the Brand component.

One optional consideration: Since brandImgSrc and brandImgAlt remain valid props (with brandImgProps taking precedence), you might want to keep the "Basic" example using the simpler brandImgSrc/brandImgAlt pattern and demonstrate brandImgProps in a separate example or alongside them to show precedence behavior. This would help consumers understand both usage patterns.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 94a2c42 and 3ce63d1.

📒 Files selected for processing (2)
  • packages/react-core/src/components/LoginPage/examples/LoginPage.md
  • packages/react-core/src/components/LoginPage/examples/LoginPageBasic.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build, test & deploy
  • GitHub Check: Build
🔇 Additional comments (1)
packages/react-core/src/components/LoginPage/examples/LoginPage.md (1)

35-36: LGTM!

Clear documentation of the new brandImgProps feature and its precedence over brandImgSrc. This aligns well with the PR objectives.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug - LoginPage - Brand is always created even if optional attributes empty Bug - LoginPage - Brand does not allow props passage down

3 participants