Skip to content

Conversation

@RackweLLizm
Copy link

@codesandbox
Copy link

codesandbox bot commented May 9, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@vercel
Copy link

vercel bot commented May 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-awesome-query-builder-examples ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 9, 2025 4:21pm
react-awesome-query-builder-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 9, 2025 4:21pm
react-awesome-query-builder-sandbox-next ✅ Ready (Inspect) Visit Preview May 9, 2025 4:21pm

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 9, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 5ae59de:

Sandbox Source
@react-awesome-query-builder/examples Configuration
@react-awesome-query-builder/sandbox Configuration
@react-awesome-query-builder/sandbox-simple Configuration
@react-awesome-query-builder/sandbox-next Configuration

@ukrbublik
Copy link
Owner

Please resolve conflict with master

@ukrbublik ukrbublik requested a review from Copilot May 16, 2025 14:25
Copy link

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 addresses an issue where the list values auto-complete filter wasn’t refreshing when the left panel changed.

  • Added a new parameter "field" to trigger refreshes when the panel changes
  • Refactored list values calculation to use React.useMemo with improved fallback handling
  • Updated debouncing logic for loading list values to recalculate on dependency changes

// const listValues = asyncFetch
// ? (selectedAsyncListValues ? mergeListValues(asyncListValues, nSelectedAsyncListValues, true) : asyncListValues)
// : staticListValues;
const listValues = React.useMemo(() => {
Copy link

Copilot AI May 16, 2025

Choose a reason for hiding this comment

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

Ensure both async and static list values are consistently converted to arrays. Consider clarifying in an inline comment why an empty array is used as a fallback in the memoized computation.

Suggested change
const listValues = React.useMemo(() => {
const listValues = React.useMemo(() => {
// Ensure consistent array handling:
// - For async values, fallback to an empty array if asyncListValues is undefined.
// - For static values, convert to an array using listValuesToArray.
// This prevents runtime errors and ensures compatibility with downstream operations.

Copilot uses AI. Check for mistakes.
}
setLoadingCnt(x => (x - 1));
setIsLoadingMore(false);
};
Copy link

Copilot AI May 16, 2025

Choose a reason for hiding this comment

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

loadListValues is defined inline and may change on every render, causing the debounced function to be recreated frequently. Consider memoizing loadListValues itself to ensure a stable reference and avoid unnecessary re-instantiation of the debounced function.

Suggested change
};
}, [fetchListValues, setAsyncListValues, setLoadingCnt, setIsLoadingMore, componentIsMounted]);

Copilot uses AI. Check for mistakes.

React.useEffect(() => {
setAsyncListValues(undefined);
}, [field]);
Copy link

Copilot AI May 16, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider adding a brief comment explaining why async list values are reset when the field changes to improve code clarity and maintainability.

Copilot uses AI. Check for mistakes.
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.

2 participants