diff --git a/.changeset/perfect-guests-raise.md b/.changeset/perfect-guests-raise.md new file mode 100644 index 0000000000..5182fa15b6 --- /dev/null +++ b/.changeset/perfect-guests-raise.md @@ -0,0 +1,5 @@ +--- +"@khanacademy/perseus-editor": patch +--- + +Remove unused prop, optionRenderer, from dropdown-option component diff --git a/packages/perseus-editor/src/components/dropdown-option.tsx b/packages/perseus-editor/src/components/dropdown-option.tsx index 3dd02548f6..693d3a43c1 100644 --- a/packages/perseus-editor/src/components/dropdown-option.tsx +++ b/packages/perseus-editor/src/components/dropdown-option.tsx @@ -12,13 +12,6 @@ import ReactDOM from "react-dom"; import {focusWithChromeStickyFocusBugWorkaround} from "./util"; -type OptionRenderer = ( - children: React.ReactElement | null | undefined, - value: string, - selected: boolean, - disabled?: boolean, -) => React.ReactElement; - const {Icon} = components; const {colors} = globalStyles; @@ -43,8 +36,6 @@ type Props = { disabled?: boolean; // An event when an option is clicked onClick?: () => void; - // An optional rendering function to render the details of the option - optionRenderer?: OptionRenderer; // An optional function to call when the dropdown should close // Only relevant if the Option is inside of a dropdown menu onDropdownClose?: () => void; @@ -105,7 +96,6 @@ class Option extends React.Component { value, onClick, children, - optionRenderer, disabled, hideFocusState, testId, @@ -137,35 +127,20 @@ class Option extends React.Component { aria-label={ariaLabel} data-testid={testId} > - {optionRenderer && - optionRenderer( - /** - * This expects a `React.Element<>` but `children` is a - * `React.Node`. We can convert a `React.Node` to a - * `React.Element<>` by wrapping it in a fragment. - */ - <>{children}, - value || "", - selected || false, - disabled, + - {children} - {selected && ( - - - - )} - - )} + > + {children} + {selected && ( + + + + )} + ); } @@ -182,8 +157,6 @@ class OptionGroup extends React.Component<{ children?: Array>>; // The currently selected options selectedValues: Array; - // An optional rendering function to render the details of the options - optionRenderer?: OptionRenderer; // An override to skip the bit of top/bottom spacing around the group noMargin?: boolean; // An optional function to call when the dropdown should close @@ -207,7 +180,6 @@ class OptionGroup extends React.Component<{ children, onSelected, selectedValues, - optionRenderer, noMargin, onDropdownClose, hideFocusState, @@ -239,7 +211,6 @@ class OptionGroup extends React.Component<{ selected: selected, // @ts-expect-error - TS2532 - Object is possibly 'undefined'. onClick: () => onSelected(child.props.value), - optionRenderer: optionRenderer, ref: reference, onDropdownClose: onDropdownClose, hideFocusState: hideFocusState,