You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Fix pre-configured props handling in forms
## Issues Fixed
### Issue 1: Remote options not loading with pre-configured values
- **Problem**: When mounting ComponentFormContainer with pre-configured props, remote options dropdowns showed "No options" even though the API returned data
- **Root Cause**: queryDisabledIdx initialization used _configuredProps (empty) instead of actual configuredProps, incorrectly blocking queries. RemoteOptionsContainer also didn't sync cached query data with component state on remount
- **Files**: form-context.tsx, RemoteOptionsContainer.tsx
### Issue 2: Optional props not auto-enabling when pre-configured
- **Problem**: Optional fields with saved values were hidden when switching back to a previously configured component
- **Root Cause**: enabledOptionalProps reset on component change, never re-enabling optional fields that had values
- **File**: form-context.tsx
### Issue 3: Optional prop values lost during state sync
- **Problem**: Optional field values were discarded during the state synchronization effect if the field wasn't enabled
- **Root Cause**: Sync effect skipped disabled optional props entirely
- **File**: form-context.tsx
## Fixes Applied
### form-context.tsx
1. Fixed queryDisabledIdx initialization to use configuredProps instead of _configuredProps
- Changed dependency from _configuredProps to component.key
- Ensures blocking index is calculated from actual current values including parent-passed props
2. Added useEffect to auto-enable optional props with values
- Runs when component key or configurableProps/configuredProps change
- Automatically enables any optional props that have values in configuredProps
- Ensures optional fields with saved values are shown on mount
3. Modified sync effect to preserve optional prop values
- Optional props that aren't enabled still have their values preserved
- Prevents data loss during state synchronization
### RemoteOptionsContainer.tsx
1. Destructured data from useQuery return
- Added data to destructured values to track query results
2. Modified queryFn to return pageable object
- Changed from returning just raw data array to returning full newPageable state object
- Enables proper state syncing
3. Added useEffect to sync pageable state with query data
- Handles both fresh API calls and React Query cached returns
- When cached data is returned, queryFn doesn't run but useEffect syncs the state
- Ensures options populate correctly on component remount
## Expected Behavior After Fixes
✓ Remote option fields load correctly when mounting with pre-configured values
✓ Dropdown shows fetched options even when using cached data
✓ Optional fields with saved values are automatically enabled and visible
✓ No data loss when switching between components
✓ Smooth component switching with all values and options preserved
🤖 Generated with Claude Code
Co-Authored-By: Claude <[email protected]>
* fix: clear dropdown options when dependent field changes
When a dependent field changes (e.g., Channel Type: "Channels" → "User/Direct Message"),
the Channel dropdown should replace its options instead of accumulating them.
The fix uses page-based logic to determine whether to replace or append options:
- page === 0 (fresh query): Replace options with new data
- page > 0 (pagination): Append options to existing data
When dependent fields change, the useEffect resets page to 0, which triggers
the queryFn to replace options instead of appending. This prevents accumulation
of options from different queries.
Additionally, the allValues Set is reset on fresh queries to ensure deduplication
starts fresh, not carrying over values from the previous query.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* fix: prevent duplicate API calls from race condition in form state
When a field value changes, two /configure API calls were being made:
1. First call with empty configured_props: {}
2. Second call with correct configured_props: {field: value}
Root cause: In setConfiguredProp, updateConfiguredPropsQueryDisabledIdx was called
synchronously, updating queryDisabledIdx state before configuredProps state update
completed. This caused children to re-render twice with mismatched state.
Fix: Move queryDisabledIdx update to a reactive useEffect that watches configuredProps
changes. This ensures both state updates complete before children re-render, preventing
the duplicate API call with stale data.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* fix: handle integer dropdown values and error states properly
Two related fixes to prevent field value loss and crashes:
1. Preserve label-value format for integer props
When integer properties with remoteOptions (like worksheetId) are selected
from dropdowns, the values are stored in label-value format: {__lv: {label, value}}.
The sync effect was incorrectly deleting these values because they weren't
pure numbers. Now preserves __lv format for remote option dropdowns.
2. Return proper pageable structure on error in RemoteOptionsContainer
When /configure returns an error, queryFn was returning [] instead of
the expected pageable object {page, data, prevContext, values}. This caused
pageable.data.map() to crash. Now returns proper structure on error to
prevent crashes and display error message correctly.
Fixes:
- Worksheet ID field no longer resets after dynamic props reload
- No more crash when clearing app field
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* style: fix eslint formatting errors
* fix: add type annotations for PropOptionValue Sets
* fix: handle multi-select integer fields with __lv format
Previously, multi-select integer fields (e.g., Worksheet ID(s)) displayed
"[object Object]" instead of proper labels when populated with pre-configured
values. This occurred because:
1. form-context.tsx only checked for single __lv objects, not arrays
2. ControlSelect.tsx tried to sanitize entire arrays instead of individual items
Changes:
- form-context.tsx: Check for both single __lv objects and arrays of __lv objects
to preserve multi-select values during sync
- ControlSelect.tsx: Extract array contents from __lv wrapper and map each item
through sanitizeOption for proper rendering
This completes the fix for pre-configured props handling with remote options.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Code cleanup and PR feedback
* More PR feedback and code cleanup
* Version and changelog
* PR feedback
* Update form-context.tsx
* some code cleanup
* more cleanup
---------
Co-authored-by: Roopak Nijhara <[email protected]>
Co-authored-by: Claude <[email protected]>
0 commit comments