Skip to content

Thulasizwe/bug/3259#4610

Open
czwe-01 wants to merge 11 commits intoshesha-io:mainfrom
czwe-01:thulasizwe/bug/3259
Open

Thulasizwe/bug/3259#4610
czwe-01 wants to merge 11 commits intoshesha-io:mainfrom
czwe-01:thulasizwe/bug/3259

Conversation

@czwe-01
Copy link
Copy Markdown
Collaborator

@czwe-01 czwe-01 commented Mar 17, 2026

#3259
Enhance form designer with active settings tab management and reactive updates

  • Added state management for active settings tab key in form designer.
  • Implemented callback ref for settings panel to trigger re-renders.
  • Updated components to utilize new active settings tab key functionality.
  • Improved handling of settings panel element for better reactivity.

Summary by CodeRabbit

  • New Features

    • Settings tab selection is now persisted and restored across sessions; searching or filtering tabs will respect and update the persisted selection.
  • Style

    • Minor formatting cleanup.

czwe-01 added 4 commits March 16, 2026 09:28
…eactive updates

- Added state management for active settings tab key in form designer.
- Implemented callback ref for settings panel to trigger re-renders.
- Updated components to utilize new active settings tab key functionality.
- Improved handling of settings panel element for better reactivity.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 17, 2026

Walkthrough

Centralizes active settings tab key into the FormDesigner provider: adds state, setter, and subscription event; exposes a hook to read the value; and updates SearchableTabsComponent to use the provider-backed key instead of local React state. Small whitespace change in a panel file.

Changes

Cohort / File(s) Summary
Form Designer State Infrastructure
shesha-reactjs/src/providers/formDesigner/contexts.tsx, shesha-reactjs/src/providers/formDesigner/instance.ts, shesha-reactjs/src/providers/formDesigner/models.ts
Added activeSettingsTabKey field and setActiveSettingsTabKey() method to the FormDesigner instance/state and introduced the 'settings-tab' subscription type.
Form Designer Public API
shesha-reactjs/src/providers/formDesigner/index.tsx
Added useFormDesignerActiveSettingsTabKey() hook that subscribes to 'settings-tab' updates and returns the current active settings tab key.
Tab Component Integration
shesha-reactjs/src/designer-components/propertiesTabs/searchableTabsComponent.tsx
Replaced local activeTabKey state with provider-backed activeSettingsTabKey; tab change handlers, auto-switch, and validity effects now call setActiveSettingsTabKey(...) and include formDesigner in effect dependencies.
Housekeeping
shesha-reactjs/src/components/formDesigner/componentPropertiesPanel/index.tsx
Added trailing blank line.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Component as "SearchableTabsComponent"
  participant Hook as "useFormDesignerActiveSettingsTabKey()"
  participant Provider as "FormDesignerInstance"
  participant Subscribers as "Other Subscribers"

  Component->>Hook: read activeSettingsTabKey
  Component->>Provider: setActiveSettingsTabKey(newKey)
  Provider-->>Provider: update activeSettingsTabKey
  Provider->>Subscribers: notify 'settings-tab' subscribers
  Subscribers-->>Component: (optional) react to update
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped from local state to one shared and true,

Keys now remembered in a handy queue.
Tabs whisper to the Provider with a gentle thud,
Subscribers listen, keeping behavior snug.
Hooray — one place to hop back to! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'Thulasizwe/bug/3259' is a branch name reference that does not clearly describe the actual changes made. It references an issue number but provides no meaningful information about what was fixed or changed. Use a descriptive title that summarizes the main change, such as 'Add state management for active settings tab key in form designer' or 'Persist active settings tab state across form designer updates'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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

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
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.

Caution

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

⚠️ Outside diff range comments (1)
shesha-reactjs/src/designer-components/propertiesTabs/searchableTabsComponent.tsx (1)

162-178: 🧹 Nitpick | 🔵 Trivial

Consider memoizing newFilteredTabs to avoid unnecessary effect executions.

Both useEffect hooks at lines 162–171 and 174–178 include newFilteredTabs in their dependency arrays. Since newFilteredTabs is computed inline during render, it receives a new reference on every render, causing these effects to fire repeatedly even when the actual tab data hasn't changed.

While setActiveSettingsTabKey has an early-return guard preventing unnecessary subscriber notifications, the effects still execute on every render, which is suboptimal.

♻️ Suggested refactor: wrap newFilteredTabs computation in useMemo
+import React, { useEffect, useRef, useState, useCallback, useMemo } from 'react';
-import React, { useEffect, useRef, useState, useCallback } from 'react';

Then wrap the newFilteredTabs computation:

-  const newFilteredTabs = tabs
+  const newFilteredTabs = useMemo(() => tabs
     .map((tab: any, index: number) => {
       // ... existing mapping logic
     })
-    .filter((tab) => !tab.hidden);
+    .filter((tab) => !tab.hidden), [tabs, searchQuery, formState.name, formActions, model, styles.searchField]);

Note: The dependency array will need to include all values used in the computation. Since isComponentHidden mutates component.inputs, you may need to refactor that as well to ensure stable references.

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

In
`@shesha-reactjs/src/designer-components/propertiesTabs/searchableTabsComponent.tsx`
around lines 162 - 178, newFilteredTabs is recomputed each render causing the
two useEffect hooks (the one that sets the first visible tab on search and the
one that ensures a valid active tab) to run unnecessarily; wrap the computation
of newFilteredTabs in a useMemo (identify the existing newFilteredTabs
expression in searchableTabsComponent.tsx) and supply a dependency array
containing the true inputs used to compute it, then use the memoized
newFilteredTabs in both useEffect calls; also eliminate or refactor any mutation
inside isComponentHidden (it currently mutates component.inputs) so the memo can
rely on stable input references, and finally adjust the useEffect dependency
arrays to depend on the memoized newFilteredTabs (and any other stable
primitives) instead of the transient inline value.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In
`@shesha-reactjs/src/designer-components/propertiesTabs/searchableTabsComponent.tsx`:
- Around line 162-178: newFilteredTabs is recomputed each render causing the two
useEffect hooks (the one that sets the first visible tab on search and the one
that ensures a valid active tab) to run unnecessarily; wrap the computation of
newFilteredTabs in a useMemo (identify the existing newFilteredTabs expression
in searchableTabsComponent.tsx) and supply a dependency array containing the
true inputs used to compute it, then use the memoized newFilteredTabs in both
useEffect calls; also eliminate or refactor any mutation inside
isComponentHidden (it currently mutates component.inputs) so the memo can rely
on stable input references, and finally adjust the useEffect dependency arrays
to depend on the memoized newFilteredTabs (and any other stable primitives)
instead of the transient inline value.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8dee9277-030a-4c11-9e01-cee413b2b7de

📥 Commits

Reviewing files that changed from the base of the PR and between 97daf5e and a1e1554.

📒 Files selected for processing (6)
  • shesha-reactjs/src/components/formDesigner/componentPropertiesPanel/index.tsx
  • shesha-reactjs/src/designer-components/propertiesTabs/searchableTabsComponent.tsx
  • shesha-reactjs/src/providers/formDesigner/contexts.tsx
  • shesha-reactjs/src/providers/formDesigner/index.tsx
  • shesha-reactjs/src/providers/formDesigner/instance.ts
  • shesha-reactjs/src/providers/formDesigner/models.ts

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 the current code and only fix it if needed.

Inline comments:
In
`@shesha-reactjs/src/designer-components/propertiesTabs/searchableTabsComponent.tsx`:
- Around line 25-29: The component currently hardcodes '1' when picking
activeTabKey and falls back to newFilteredTabs[0].key when a persisted key is
stale, which ignores the model's configured defaultActiveKey; update the logic
in searchableTabsComponent to first consult the form model's defaultActiveKey
(via useFormDesigner -> formDesigner.model.defaultActiveKey) before falling back
to '1' (i.e. activeTabKey = persistedActiveTabKey ??
formDesigner?.model?.defaultActiveKey ?? '1'), and likewise change the
stale-persistence recovery code (where it currently selects
newFilteredTabs[0].key) to prefer formDesigner.model.defaultActiveKey when
present, then newFilteredTabs[0].key as the final fallback.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: caedb59d-cdfc-448a-a7f2-b86411a3c6bd

📥 Commits

Reviewing files that changed from the base of the PR and between a1e1554 and 25a43c3.

📒 Files selected for processing (1)
  • shesha-reactjs/src/designer-components/propertiesTabs/searchableTabsComponent.tsx

@czwe-01 czwe-01 marked this pull request as ready for review March 27, 2026 12:40
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.

1 participant