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

Fix blocks when useOnce is true #3988

Merged
merged 2 commits into from
Dec 15, 2017
Merged

Fix blocks when useOnce is true #3988

merged 2 commits into from
Dec 15, 2017

Conversation

Rahmon
Copy link
Contributor

@Rahmon Rahmon commented Dec 14, 2017

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:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows has proper inline documentation.

@@ -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 }
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

@aduth aduth left a 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 );
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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 😄

Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants