volto
volto copied to clipboard
TextWidget: Pass onChange in iconAction
It would be useful to have access to onChange function in iconAction, for exemple to implement clear action.
iconAction function ex:
<TextWidget
...
iconAction={(e, id, onChange) => {
e.target.value = '';
onChange(id, undefined);
}}
/>
@mcasagrande18
You can still do it, given the schema property, and access to the props:
url: {
title: intl.formatMessage(messages.image),
value: imageUrl,
icon: props.data.url ? clearSVG : navTreeSVG,
iconAction: props.data.url
? () => {
props.resetSubmitUrl();
props.onChangeBlock(props.block, {
...props.data,
url: '',
});
}
: () =>
props.openObjectBrowser({
onSelectItem: props.onSelectItem,
}),
},