Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icons in IconsBlock not updating #404

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@

- Aggiunta la possibilità di selezionare la dimensione dell'immagine nel blocco Alert, inoltre è stato aggiornato anche il widget per la selezione del colore di sfondo.

### Fix

- Le icone del Blocco Icone si aggiornano istantaneamente quando vengono cambiate

## Versione 10.3.0 (08/11/2023)

### Fix
Expand Down
32 changes: 25 additions & 7 deletions src/components/ItaliaTheme/Blocks/IconBlocks/Block/EditBlock.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class EditBlock extends SubblockEdit {
this.state = {
focusOn: 'title',
};
this.state = {
...this.state,
icon: '',
};
this.subblock_ref = React.createRef();
}

Expand All @@ -61,6 +65,19 @@ class EditBlock extends SubblockEdit {
}
}
});
this.setIconValues(this.props.data);
}

componentDidUpdate(prevProps) {
if (prevProps.data !== this.props.data) {
this.setIconValues(this.props.data);
}
}

setIconValues(data) {
this.setState({
icon: data.icon,
});
}
/**
* Render method.
Expand All @@ -84,13 +101,14 @@ class EditBlock extends SubblockEdit {
>
<CardBody tag="div">
<div className="iconblock-icon">
{this.props.data.icon?.length > 0 ? (
<Icon icon={this.props.data.icon} />
) : (
<div className="icon-placeholder">
{this.props.intl.formatMessage(messages.select_an_icon)}
</div>
)}
{this.state.icon === this.props.data.icon &&
(this.props.data.icon?.length > 0 ? (
<Icon icon={this.props.data.icon} />
) : (
<div className="icon-placeholder">
{this.props.intl.formatMessage(messages.select_an_icon)}
</div>
))}
</div>

<div className="iconblock-title">
Expand Down