fix: update dropdown trigger label on select#2515
fix: update dropdown trigger label on select#2515Branc0 wants to merge 2 commits intosuperdoc-dev:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c8c95a75ff
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (option?.label) { | ||
| item.label.value = option.label; |
There was a problem hiding this comment.
Avoid setting labels on dropdowns that are meant to stay icon-only
handleSelect now assigns item.label.value for every option that has a label. That fixes font-family/font-size, but it also changes the lineHeight dropdown, which is configured as an icon-only control with no initial label in packages/super-editor/src/components/toolbar/defaultItems.js:1019-1043; its state sync in super-toolbar.js:996-1001 only updates selectedValue, so the new label will stick even after the caret moves elsewhere. Because ToolbarButton.vue:118-120 renders any truthy label, selecting a line height will start showing text like 1.50 in the trigger and widen the control unexpectedly.
Useful? React with 👍 / 👎.
Summary
When a user selects an option from a toolbar dropdown,
handleSelectupdatesselectedValueand emits the command, but does not update the reactiveitem.labelused byToolbarButtonin the dropdown trigger. The visible label could stay on the initial value even though the selection changed.dropdown.bug.mov
Steps to reproduce
Solution
This change sets
item.labelfromoption.labelwhen there's a change in the selection, keeping the trigger text in sync with the selection.