Skip to content

fix: early return in toolbar button to avoid unneeded calls to useInt…#24

Open
Arukuen wants to merge 3 commits intodevelopfrom
fix/23-kadence-tabs
Open

fix: early return in toolbar button to avoid unneeded calls to useInt…#24
Arukuen wants to merge 3 commits intodevelopfrom
fix/23-kadence-tabs

Conversation

@Arukuen
Copy link
Copy Markdown
Contributor

@Arukuen Arukuen commented May 5, 2026

…eractions

fixes #23

Summary by CodeRabbit

  • Refactor
    • Internal interaction-selection logic reorganized for clearer implementation and easier future maintenance. No changes to user-facing behavior; existing features should behave identically.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6fd1a2ca-0bdf-41a4-8b1e-85beab72ddb3

📥 Commits

Reviewing files that changed from the base of the PR and between 8ca2974 and 851b6bc.

📒 Files selected for processing (1)
  • src/editor/hooks/use-interactions.js
✅ Files skipped from review due to trivial changes (1)
  • src/editor/hooks/use-interactions.js

📝 Walkthrough

Walkthrough

The useInteractions hook refactors how filtered interactions are derived: interactionsFiltered is now computed in a separate useSelect (filtering data.interactions with isInteractionShown) and the hook return spreads ...data while explicitly returning loadingError and interactionsFiltered.

Changes

State Selection Refactoring

Layer / File(s) Summary
Primary Selector
src/editor/hooks/use-interactions.js
Main useSelect now returns interactions, setInteractions, updateInteraction, and deleteInteraction without computing interactionsFiltered.
Derived Selector
src/editor/hooks/use-interactions.js
A new, separate useSelect computes interactionsFiltered by filtering data.interactions with isInteractionShown.
Return Restructuring
src/editor/hooks/use-interactions.js
Hook return now explicitly includes loadingError and interactionsFiltered, and spreads ...data for the remaining fields instead of listing them manually.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

"I nudge the selector trail,
splitting filters with a tail.
Spreads and hops in tidy rows,
no more inline filter woes.
A rabbit cheers — tidy flows!" 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is partially related to the changeset - it mentions avoiding unnecessary calls but is truncated and doesn't fully convey the refactoring of the useInteractions hook. Complete the truncated title to fully describe the actual changes: refactoring useInteractions to use dedicated selector for filtering interactions.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The pull request code changes refactor the useInteractions hook filtering logic, directly addressing the root cause of unnecessary re-renders that was resetting the Kadence inspector tab.
Out of Scope Changes check ✅ Passed All changes are scoped to the useInteractions hook refactoring, directly addressing the linked issue without introducing unrelated modifications.
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
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/23-kadence-tabs

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

🤖 Pull request artifacts

file commit
pr24-interactions-24-merge.zip 851b6bc

github-actions Bot added a commit that referenced this pull request May 5, 2026
Copy link
Copy Markdown
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/editor/plugins/block-toolbar-button/index.js (1)

65-65: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Typo: "Reeset" → "Reset".

-		// Reeset the popover mode when the popover closes.
+		// Reset the popover mode when the popover closes.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/editor/plugins/block-toolbar-button/index.js` at line 65, Fix the typo in
the comment inside src/editor/plugins/block-toolbar-button/index.js: change
"Reeset the popover mode when the popover closes." to "Reset the popover mode
when the popover closes." so the inline comment above the popover-handling code
(in the block-toolbar-button module) reads correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/editor/plugins/block-toolbar-button/index.js`:
- Around line 36-46: The conditional early-return after computing
hasAnchorAttribute causes hooks (useInteractions, useBlockHasInteraction,
useWithShift, useDispatch, the extra useState and useEffect calls) to be called
only when hasAnchorAttribute is true which breaks the Rules of Hooks; fix by
extracting the hook-using logic into a new inner component (e.g.,
BlockToolbarButtonInner) that accepts props and uses
isPopoverOpen/setIsPopoverOpen, useInteractions, useBlockHasInteraction,
useWithShift, useDispatch, and the useEffect hooks; keep the outer component to
only compute hasAnchorAttribute (using useSelect) and then return either
<BlockEdit {...props} /> when !hasAnchorAttribute or <BlockToolbarButtonInner
{...props} /> when true so hooks are called unconditionally within the inner
component; also correct the typo "Reeset" to "Reset".

---

Outside diff comments:
In `@src/editor/plugins/block-toolbar-button/index.js`:
- Line 65: Fix the typo in the comment inside
src/editor/plugins/block-toolbar-button/index.js: change "Reeset the popover
mode when the popover closes." to "Reset the popover mode when the popover
closes." so the inline comment above the popover-handling code (in the
block-toolbar-button module) reads correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b0d831ea-f083-4123-a16a-e30edce5c4c5

📥 Commits

Reviewing files that changed from the base of the PR and between eacb69f and bbd7e8e.

📒 Files selected for processing (1)
  • src/editor/plugins/block-toolbar-button/index.js

Comment thread src/editor/plugins/block-toolbar-button/index.js Outdated
Copy link
Copy Markdown
Collaborator

@bfintal bfintal left a comment

Choose a reason for hiding this comment

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

The issue seems to be with the useInteractions hook, so let's fix the hook itself instead of returning early to avoid using the hook

…ditor re-renders and prevent Kadence inspector tab reset
Copy link
Copy Markdown
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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/editor/hooks/use-interactions.js`:
- Around line 256-258: The selector passed to useSelect (used to compute
interactionsFiltered) currently depends on the whole data object ([data])
causing unnecessary re-runs; change the dependency array to [data.interactions]
so the selector only re-evaluates when interactions actually change. Locate the
useSelect call that defines interactionsFiltered and update its dependency array
accordingly (the callback uses isInteractionShown and data.interactions).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5401ae40-e7b7-410f-b1db-4b7be1448380

📥 Commits

Reviewing files that changed from the base of the PR and between bbd7e8e and 8ca2974.

📒 Files selected for processing (1)
  • src/editor/hooks/use-interactions.js

Comment thread src/editor/hooks/use-interactions.js Outdated
github-actions Bot added a commit that referenced this pull request May 5, 2026
github-actions Bot added a commit that referenced this pull request May 5, 2026
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.

Kadence Blocks compatibility - Active tab resets to general when interactions is enabled

2 participants