Skip to content

Commit

Permalink
Move onClick function inline.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZebulanStanphill committed Oct 9, 2020
1 parent 502b001 commit 67463b4
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ export default function ContentJustificationDropdown( {
toggleProps,
value,
} ) {
function applyOrUnset( align ) {
return () => onChange( value === align ? undefined : align );
}

return (
<DropdownMenu
icon={ CONTROLS[ value ]?.icon ?? DEFAULT_ICON }
Expand All @@ -65,7 +61,10 @@ export default function ContentJustificationDropdown( {
...CONTROLS[ allowedValue ],
isActive: value === allowedValue,
role: 'menuitemradio',
onClick: applyOrUnset( allowedValue ),
onClick: () =>
onChange(
value === allowedValue ? undefined : allowedValue
),
};
} ) }
toggleProps={ toggleProps }
Expand Down

0 comments on commit 67463b4

Please sign in to comment.