-
Notifications
You must be signed in to change notification settings - Fork 6
feat(CommandMenu): add component #720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: aca5a85 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
📦 NPM canary releaseDeployed canary version 0.0.0-canary-70fb30b. |
🧪 Storybook is successfully deployed!
|
🏋️ Size limit report
Click here if you want to find out what is changed in this build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Tree State Initialization Timing Issue
The handleSelectionChange
function attempts to access treeState.collection.getKeys()
before treeState
is defined. This causes a ReferenceError
at runtime when the 'all' selection case is triggered, as handleSelectionChange
is used in mergeProps
before treeState
is initialized.
src/components/actions/CommandMenu/CommandMenu.tsx#L120-L136
cube-ui-kit/src/components/actions/CommandMenu/CommandMenu.tsx
Lines 120 to 136 in aca5a85
const handleSelectionChange = onSelectionChange | |
? (keys: any) => { | |
if (keys === 'all') { | |
// Handle 'all' selection case - collect all available keys | |
const allKeys = Array.from(treeState.collection.getKeys()).map( | |
(key: any) => String(key), | |
); | |
onSelectionChange(allKeys); | |
} else if (keys instanceof Set) { | |
onSelectionChange(Array.from(keys).map((key) => String(key))); | |
} else { | |
onSelectionChange([]); | |
} | |
} | |
: undefined; | |
Bug: Function Accesses Undefined State Variable
The handleSelectionChange
function attempts to access state.collection.getKeys()
before the state
variable is defined. Since handleSelectionChange
is passed to mergeProps
prior to state
's initialization, this results in a ReferenceError
when the selection change handler is invoked, particularly for the 'all' selection case.
src/components/actions/Menu/Menu.tsx#L97-L113
cube-ui-kit/src/components/actions/Menu/Menu.tsx
Lines 97 to 113 in aca5a85
const handleSelectionChange = onSelectionChange | |
? (keys: any) => { | |
if (keys === 'all') { | |
// Handle 'all' selection case - collect all available keys | |
const allKeys = Array.from(state.collection.getKeys()).map( | |
(key: any) => String(key), | |
); | |
onSelectionChange(allKeys); | |
} else if (keys instanceof Set) { | |
onSelectionChange(Array.from(keys).map((key) => String(key))); | |
} else { | |
onSelectionChange([]); | |
} | |
} | |
: undefined; | |
Was this report helpful? Give feedback by reacting with 👍 or 👎
No description provided.