Skip to content

Commit

Permalink
Reusable blocks: Fix dismiss notice after error (#28015)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras authored Jan 7, 2021
1 parent 4834daf commit 62e074b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
15 changes: 13 additions & 2 deletions packages/list-reusable-blocks/src/components/import-form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ImportForm extends Component {
}

onChangeFile( event ) {
this.setState( { file: event.target.files[ 0 ] } );
this.setState( { file: event.target.files[ 0 ], error: null } );
}

onSubmit( event ) {
Expand Down Expand Up @@ -71,6 +71,10 @@ class ImportForm extends Component {
} );
}

onDismissError() {
this.setState( { error: null } );
}

render() {
const { instanceId } = this.props;
const { file, isLoading, error } = this.state;
Expand All @@ -80,7 +84,14 @@ class ImportForm extends Component {
className="list-reusable-blocks-import-form"
onSubmit={ this.onSubmit }
>
{ error && <Notice status="error">{ error }</Notice> }
{ error && (
<Notice
status="error"
onRemove={ () => this.onDismissError() }
>
{ error }
</Notice>
) }
<label
htmlFor={ inputId }
className="list-reusable-blocks-import-form__label"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@
}

.list-reusable-blocks-import-form__button {
margin-top: 20px;
margin-top: 10px;
margin-bottom: 10px;
float: right;
}

.list-reusable-blocks-import-form .components-notice__content {
margin: 0;
.list-reusable-blocks-import-form {
.components-notice__content {
margin: 0;
}

.components-notice.is-dismissible {
padding-right: 0;
margin: 5px 0;
}
}

0 comments on commit 62e074b

Please sign in to comment.