fix: added possibility to revert back to default profile picture (#43962)

* added possibility to revert to default profile picture

* removed required from picture input

* remove addPlaceholderImage and replaced with empty string

* added test for empty string to avatar-renderer
This commit is contained in:
AndreiD049
2021-10-25 22:06:32 +03:00
committed by GitHub
parent 9abc5f66ba
commit a07a16b38b
4 changed files with 6 additions and 8 deletions

View File

@@ -33,7 +33,7 @@ function AvatarRenderer({
const isPlaceHolderImage =
!isPictureValid ||
/example.com|identicon.org/.test(picture) ||
/example.com|identicon.org|^$/.test(picture) ||
picture === defaultUserImage;
return (

View File

@@ -139,7 +139,10 @@ class AboutSettings extends Component<AboutProps, AboutState> {
}
loadEvent = () => this.setState({ isPictureUrlValid: true });
errorEvent = () => this.setState({ isPictureUrlValid: false });
errorEvent = () =>
this.setState(state => ({
isPictureUrlValid: state.formValues.picture === ''
}));
handlePictureChange = (e: React.FormEvent<HTMLInputElement>) => {
const value = (e.target as HTMLInputElement).value.slice(0);
@@ -214,7 +217,6 @@ class AboutSettings extends Component<AboutProps, AboutState> {
</ControlLabel>
<FormControl
onChange={this.handlePictureChange}
required={true}
type='url'
value={picture}
/>