Skip to content

Commit 7761417

Browse files
committed
change(text-align): add clear selection if it's not found as last option
1 parent fc26773 commit 7761417

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Widgets/TextAlign.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@ export const TEXT_ALIGN_VALUE_MAP = [
1313
['right', alignRightSVG, 'Right align'],
1414
['center', alignCenterSVG, 'Center align'],
1515
['justify', alignJustifySVG, 'Justify align'],
16-
['', clearSVG, 'Clear selection'],
1716
];
1817

1918
export default (props) => {
2019
const { value, onChange, id, actions = TEXT_ALIGN_VALUE_MAP } = props;
20+
// add clear selection button to the actions mapping if it's not already present
21+
if (actions[actions.length - 1][0] !== '') {
22+
actions.push(['', clearSVG, 'Clear selection']);
23+
}
24+
2125
return (
2226
<FormFieldWrapper {...props}>
2327
<div className="align-tools">

0 commit comments

Comments
 (0)