Skip to content

frontend: Dialog: move useCallback before early return to fix rules-of-hooks#5208

Open
jedbillyb wants to merge 3 commits intokubernetes-sigs:mainfrom
jedbillyb:fix/dialog-rules-of-hooks
Open

frontend: Dialog: move useCallback before early return to fix rules-of-hooks#5208
jedbillyb wants to merge 3 commits intokubernetes-sigs:mainfrom
jedbillyb:fix/dialog-rules-of-hooks

Conversation

@jedbillyb
Copy link
Copy Markdown
Contributor

Fixes #5186

Moves React.useCallback in DialogTitle to before the early return
guard clause, satisfying rules-of-hooks. Also adds focusTitle to the
dependency array which was previously missing.

Steps to test:

  • Run npx eslint src/components/common/Dialog.tsx - no rules-of-hooks warnings

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jedbillyb
Once this PR has been reviewed and has the lgtm label, please assign joaquimrocha 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

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 23, 2026
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 23, 2026
@kahirokunn
Copy link
Copy Markdown
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 23, 2026
@illume illume requested a review from Copilot April 23, 2026 13:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an ESLint react-hooks/rules-of-hooks violation in DialogTitle by ensuring useCallback is always invoked before any early returns, and updates the hook dependencies to match referenced props.

Changes:

  • Move the focusedRef React.useCallback above the guard-clause early return in DialogTitle.
  • Add focusTitle to the useCallback dependency array (previously missing).

Comment on lines +49 to +54
(node: HTMLElement) => {
if (node !== null) {
if (focusTitle) {
node.setAttribute('tabindex', '-1');
node.focus();
}
Copy link
Copy Markdown
Contributor

@illume illume left a comment

Choose a reason for hiding this comment

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

Sorry, another PR was merged and there's now a git conflict.

Are you able to fix the git conflict?

illume

This comment was marked as duplicate.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 23, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 23, 2026
@jedbillyb
Copy link
Copy Markdown
Contributor Author

@illume fixed!

Copy link
Copy Markdown
Contributor

@skoeva skoeva left a comment

Choose a reason for hiding this comment

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

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

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

6 participants