Skip to content

Commit

Permalink
feat(richtext-lexical)!: improve floating select menu Dropdown classN…
Browse files Browse the repository at this point in the history
…ames (#4444)

Breaking: Dropdown component has a new mandatory sectionKey prop
  • Loading branch information
AlessioGr committed Dec 11, 2023
1 parent 9babf68 commit 9331204
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export function DropDown({
type="button"
>
<Icon />
<i className={`${buttonClassName}-caret`} />
<i className="floating-select-toolbar-popup__dropdown-caret" />
</button>

{showDropDown &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,23 @@ export const ToolbarDropdown = ({
classNames,
editor,
entries,
sectionKey,
}: {
Icon?: React.FC
anchorElem: HTMLElement
classNames?: string[]
editor: LexicalEditor
entries: FloatingToolbarSectionEntry[]
sectionKey: string
}) => {
return (
<DropDown
Icon={Icon}
buttonAriaLabel="Formatting options"
buttonClassName={[baseClass, ...(classNames || [])].filter(Boolean).join(' ')}
buttonAriaLabel={`${sectionKey} dropdown`}
buttonClassName={[baseClass, `${baseClass}-${sectionKey}`, ...(classNames || [])]
.filter(Boolean)
.join(' ')}
key={sectionKey}
>
{entries.length &&
entries.map((entry) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,16 @@ function ToolbarSection({
anchorElem={anchorElem}
editor={editor}
entries={section.entries}
sectionKey={section.key}
/>
</React.Suspense>
) : (
<ToolbarDropdown anchorElem={anchorElem} editor={editor} entries={section.entries} />
<ToolbarDropdown
anchorElem={anchorElem}
editor={editor}
entries={section.entries}
sectionKey={section.key}
/>
))}
{section.type === 'buttons' &&
section.entries.length &&
Expand Down

0 comments on commit 9331204

Please sign in to comment.