-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Fix blocks when useOnce is true #3988
Conversation
@@ -67,6 +67,7 @@ export class VisualEditorInserter extends Component { | |||
className="editor-inserter__block" | |||
onClick={ () => this.insertBlock( block.name ) } | |||
label={ sprintf( __( 'Insert %s' ), block.title ) } | |||
disabled={ block.useOnce } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the block hasn't been used yet in the post? Should the button not be disabled in these cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I forgot this scenario but I did a new commit and I guess now is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good 👍
@@ -40,6 +41,10 @@ export class VisualEditorInserter extends Component { | |||
onInsertBlock( createBlock( name ) ); | |||
} | |||
|
|||
isDisabledBlock( block ) { | |||
return block.useOnce && find( this.props.blocks, ( { name } ) => block.name === name ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: some
(Array#some) would be more appropriate than find
(Array#find) only because we care that it exists (boolean), and have no intent to use the found value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I still commit in this branch to do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I still commit in this branch to do that?
I'm not sure how forked branches work when a merge has already been done upstream†, but at the very least you'd still need to create a new pull request if you feel compelled to make the change.
† I'm kinda curious though if committing to your branch would allow for a new pull request 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a commit but nothing got happen here. I think I need to create a new pull request... xD
Description
Blocks can still be inserted from the list next to the inserter even if useOnce is true #3968
How Has This Been Tested?
This has been tested with "npm test", "npm run test-e2e" and manually on Chrome and Firefox.
Types of changes
Bug fix
Checklist: