FIX: Pivot Columns Dropdown Empty on First Render in "More" Menu#51
FIX: Pivot Columns Dropdown Empty on First Render in "More" Menu#51tahierhussain wants to merge 2 commits intomainfrom
Conversation
When the Pivot toolbar item was displayed inside the "More" dropdown (due to toolbar overflow), the columns dropdown appeared empty on first render. This occurred because the memoized dropdownMenu was capturing stale JSX snapshots of components. Changed from using Ant Design's menu prop to dropdownRender to ensure components are rendered fresh with current state on each dropdown open, rather than relying on cached React element references. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
| Filename | Overview |
|---|---|
| frontend/src/ide/editor/no-code-toolbar/no-code-toolbar.jsx | Replaces memoized dropdownMenu object + menu prop with a useCallback-wrapped dropdownRender function; correctly addresses all three prior review concerns (stale render, missing memoization, internal AntD class names). |
| frontend/src/ide/editor/no-code-toolbar/no-code-toolbar.css | Adds .no-code-toolbar-more-menu and .no-code-toolbar-more-item custom classes; however, pre-existing selectors targeting .ant-dropdown-menu and .ant-dropdown-menu-item (lines 68–84) are now dead code since dropdownRender bypasses AntD's menu DOM structure entirely. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[NoCodeToolbar renders] --> B{Overflow?}
B -- No --> C[All items visible in toolbar]
B -- Yes --> D[Hidden items tracked in hiddenItems state]
D --> E[renderMoreDropdown memoized via useCallback\ndeps: hiddenItems, items]
E --> F[User clicks More button]
F --> G[Dropdown opens\nAntD calls dropdownRender]
G --> H[renderMoreDropdown executes fresh\nreads latest items + hiddenItems]
H --> I[Renders div.no-code-toolbar-more-menu\nwith fresh component instances]
I --> J[Pivot and other toolbar components\nmount fresh — state initialises correctly]
J --> K[Columns dropdown shows populated options ✓]
Prompt To Fix All With AI
This is a comment left during a code review.
Path: frontend/src/ide/editor/no-code-toolbar/no-code-toolbar.css
Line: 68-84
Comment:
**Dead CSS selectors after migration to `dropdownRender`**
Now that the `Dropdown` uses `dropdownRender` instead of `menu`, AntD no longer injects an `.ant-dropdown-menu` / `.ant-dropdown-menu-item` DOM structure inside the overlay. The three rules below are unreachable and can be removed in a follow-up to keep the stylesheet tidy:
```
.no-code-toolbar-dropdown .ant-dropdown-menu /* line 68 */
.no-code-toolbar-dropdown .ant-dropdown-menu-item /* line 77 */
.no-code-toolbar-dropdown .ant-dropdown-menu-item:hover /* line 83 */
```
The replacement selectors (`.no-code-toolbar-more-menu` / `.no-code-toolbar-more-item`) correctly cover the new structure.
How can I resolve this? If you propose a fix, please make it concise.Reviews (2): Last reviewed commit: "fix: use custom classes and memoize drop..." | Re-trigger Greptile
- Replace internal Ant Design class names with custom classes (no-code-toolbar-more-menu, no-code-toolbar-more-item) - Memoize dropdownRender with useCallback to avoid unnecessary re-renders - Add CSS styles for the custom dropdown classes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
What
Why
menuprop capturing stale JSX snapshots of React componentsdropdownMenuobject was caching React element references that didn't update when the Pivot component's internal state (pivotColsOptions) changedHow
menuprop withdropdownRenderin the Dropdown componentdropdownMenuobject entirelydropdownRenderfunction executes at render time, ensuring fresh component instances with current state are rendered each time the dropdown opensTechnical Details:
<Dropdown menu={dropdownMenu} />wheredropdownMenuwas a memoized object<Dropdown dropdownRender={() => (...)} />that renders components fresh on each openCan this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
dropdownRenderinstead ofmenupropDatabase Migrations
Env Config
Relevant Docs
dropdownRendervsmenupropRelated Issues or PRs
Dependencies Versions
Notes on Testing
Testing Checklist:
How to Test:
Screenshots
Checklist
I have read and understood the Contribution Guidelines.