Skip to content

Commit

Permalink
fix: added conditions and state management to update icons
Browse files Browse the repository at this point in the history
  • Loading branch information
sabrina-bongiovanni committed Nov 14, 2023
1 parent 68c3ca5 commit 8344e7e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
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

0 comments on commit 8344e7e

Please sign in to comment.