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

Hide insertion point if a template lock exists. #5574

Merged

Conversation

jorgefilipecosta
Copy link
Member

The insertion point allows inserting a new block by clicking on it, when a template lock exists, insertion should not be possible.

Fixes: #5531

How Has This Been Tested?

Define a CPT with a template lock, verify it is not possible to insert block using the insertion point inserter if a template lock exists.

@jorgefilipecosta jorgefilipecosta added the [Type] Bug An existing feature does not function as intended label Mar 12, 2018
@jorgefilipecosta jorgefilipecosta self-assigned this Mar 12, 2018
@@ -439,7 +439,7 @@ export class BlockListBlock extends Component {
// Insertion point can only be made visible when the side inserter is
// not present, and either the block is at the extent of a selection or
// is the last block in the top-level list rendering.
const shouldShowInsertionPoint = (
const shouldShowInsertionPoint = ! isLocked && (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the block movers, we assign shouldShowMovers without consideration of isLocked, and this consideration is managed by the BlockMover component itself. Should we do that here? Or at least align the two approaches one way or the other?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we should be consistent, I updated the code to follow the same logic we now do the check for template locking inside BlockInsertionPointm, like we do for BlockMover.

@jorgefilipecosta jorgefilipecosta force-pushed the fix/hides-in-between-inserter-if-template-lock-exists branch from 85eee73 to e466394 Compare March 14, 2018 12:02
The insertion point allows inserting a new block by clicking on it, when a template lock exists, insertion should not be possible.
@jorgefilipecosta jorgefilipecosta force-pushed the fix/hides-in-between-inserter-if-template-lock-exists branch from e466394 to 127129f Compare March 16, 2018 18:38
@jorgefilipecosta jorgefilipecosta merged commit da19364 into master Mar 16, 2018
@jorgefilipecosta jorgefilipecosta deleted the fix/hides-in-between-inserter-if-template-lock-exists branch March 16, 2018 19:18
@janeschindler
Copy link

janeschindler commented Apr 24, 2019

I made a column layout today, locked the template, and still see an inserter point. Perhaps columns can't be locked from the page template?
Bildschirmfoto 2019-04-24 um 16 02 06

This is the code I'm using to make the template (part of it). I made a block called 'coltext' that only allows a limited number of options. Ideally the user shouldn't be able to add any blocks, except within the coltext block where they can only add the few I've specifically allowed there.

`
'template_lock' => 'all',
'template' => array(
array('core/paragraph', array('placeholder' => 'Text', 'className' => 'intro') ),
array('neuthalblocks/gmap', array() ),

		array( 'core/columns', array(), array(
			array( 'core/column', array(), array(
				array( 'core/columns', array(), array(
					array( 'core/column', array(), array(
						array( 'neuthalblocks/coltext', array() ),
					) ),
					array( 'core/column', array(), array(
						array( 'neuthalblocks/coltext', array() ),
					) ),
				) )
			) ),
			array( 'core/column', array(), array(
				array( 'core/columns', array(), array(
					array( 'core/column', array(), array(
						array( 'neuthalblocks/coltext', array() ),
					) ),
					array( 'core/column', array(), array(
						array( 'neuthalblocks/coltext', array() ),
					) ),
				) )
			) ),
		) ),

`

@aduth
Copy link
Member

aduth commented Apr 29, 2019

@janeschindler This was merged five days ago and hasn't yet landed in a Gutenberg plugin release, so I wouldn't expect you should see any difference yet. Gutenberg 5.6.0 will be released on Wednesday. If you are still having problems after the testing again the latest version, I'd recommend you open a new issue, as it will be the easiest way to track further improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In-between inserter ignores locking via template_lock
3 participants