diff --git a/packages/richtext-lexical/src/features/toolbars/fixed/client/Toolbar/index.tsx b/packages/richtext-lexical/src/features/toolbars/fixed/client/Toolbar/index.tsx index f4d2a51561..ab16cd5b40 100644 --- a/packages/richtext-lexical/src/features/toolbars/fixed/client/Toolbar/index.tsx +++ b/packages/richtext-lexical/src/features/toolbars/fixed/client/Toolbar/index.tsx @@ -116,7 +116,11 @@ function ToolbarGroupComponent({ ) return ( -
+
{group.type === 'dropdown' && group.items.length ? ( DropdownIcon ? ( {group.type === 'dropdown' && group.items.length ? ( diff --git a/packages/richtext-lexical/src/features/toolbars/shared/ToolbarButton/index.tsx b/packages/richtext-lexical/src/features/toolbars/shared/ToolbarButton/index.tsx index c596e5e414..efd6beea2d 100644 --- a/packages/richtext-lexical/src/features/toolbars/shared/ToolbarButton/index.tsx +++ b/packages/richtext-lexical/src/features/toolbars/shared/ToolbarButton/index.tsx @@ -63,6 +63,9 @@ export const ToolbarButton = ({ const runDeprioritized = useRunDeprioritized() useEffect(() => { + // Run on mount + void runDeprioritized(updateStates) + const listener = () => runDeprioritized(updateStates) const cleanup = mergeRegister(editor.registerUpdateListener(listener)) @@ -99,7 +102,13 @@ export const ToolbarButton = ({ }, []) return ( - ) diff --git a/packages/richtext-lexical/src/features/toolbars/shared/ToolbarDropdown/DropDown.tsx b/packages/richtext-lexical/src/features/toolbars/shared/ToolbarDropdown/DropDown.tsx index bfa2c34eaf..6e64ff36ea 100644 --- a/packages/richtext-lexical/src/features/toolbars/shared/ToolbarDropdown/DropDown.tsx +++ b/packages/richtext-lexical/src/features/toolbars/shared/ToolbarDropdown/DropDown.tsx @@ -21,6 +21,7 @@ export function DropDownItem({ enabled, Icon, item, + itemKey, tooltip, }: { active?: boolean @@ -29,6 +30,7 @@ export function DropDownItem({ enabled?: boolean Icon: React.ReactNode item: ToolbarGroupItem + itemKey: string tooltip?: string }): React.ReactNode { const className = useMemo(() => { @@ -64,6 +66,9 @@ export function DropDownItem({ buttonStyle="none" className={className} disabled={enabled === false} + extraButtonProps={{ + 'data-item-key': itemKey, + }} icon={Icon} iconPosition="left" iconStyle="none" @@ -183,6 +188,7 @@ export function DropDown({ buttonClassName, children, disabled = false, + dropdownKey, Icon, itemsContainerClassNames, label, @@ -192,6 +198,7 @@ export function DropDown({ buttonClassName: string children: ReactNode disabled?: boolean + dropdownKey: string Icon?: React.FC itemsContainerClassNames?: string[] label?: string @@ -262,6 +269,7 @@ export function DropDown({