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

Copy / Paste error core/paragraph using InnerBlocks #12774

Closed
fishstix81 opened this issue Dec 10, 2018 · 6 comments · Fixed by #14712
Closed

Copy / Paste error core/paragraph using InnerBlocks #12774

fishstix81 opened this issue Dec 10, 2018 · 6 comments · Fixed by #14712
Assignees
Labels
[Block] Paragraph Affects the Paragraph Block [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P Needs Testing Needs further testing to be confirmed.

Comments

@fishstix81
Copy link

Describe the bug
Using InnerBlocks with a nested block template, you can not copy / paste inside of the core/paragraph block. It results in a console error and the text is not copied into the block

Uncaught TypeError: r is not a function
    at t.value (index.js?ver=1542840426:formatted:830)
    at t.value (index.js?ver=1542840430:formatted:11004)
    at Object.Fg (react-dom.min.713f0afa.js:formatted:4357)
    at Eg (react-dom.min.713f0afa.js:formatted:42)
    at Hg (react-dom.min.713f0afa.js:formatted:45)
    at ae (react-dom.min.713f0afa.js:formatted:96)
    at Ig (react-dom.min.713f0afa.js:formatted:4390)
    at Hc (react-dom.min.713f0afa.js:formatted:113)
    at Jc (react-dom.min.713f0afa.js:formatted:150)
    at gh (react-dom.min.713f0afa.js:formatted:872)

core/heading works fine. If I begin typing in the core/paragraph and then copy / paste, the new text is added without the console error.

To Reproduce
Add a custom block that uses InnerBlocks with a template that includes core/pargraph. Something like

[core/column, {}, [
  [core/paragraph, {}]
]]

Expected behavior
core/paragraph should not have issues with copy / paste when used inside of a nested block

Desktop (please complete the following information):

  • OS: OsMojave
  • Browser chrom

Additional context
Gutenberg version 4.5.0

@swissspidy swissspidy added Needs Testing Needs further testing to be confirmed. [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P [Block] Paragraph Affects the Paragraph Block labels Dec 11, 2018
@pokhiii
Copy link

pokhiii commented Mar 12, 2019

This is exactly the issue I'm facing right now.

@squibbleFish Were you able to resolve this? Looks like this.props.onReplace is undefined when the string is empty.

@dannymcgee
Copy link

Having the same issue in WordPress 5.1.1. No resolution yet...

@pokhiii
Copy link

pokhiii commented Mar 27, 2019

@youknowriad @aduth @ellatrix Could you guys please do something about this bug?

@dannymcgee
Copy link

dannymcgee commented Mar 27, 2019

In my case, it seems that removing templateLock="all" from the InnerBlocks component fixed the problem. I noticed that some other custom nested blocks I had didn't have this issue, so decided to give that a shot and it seems to be the culprit.

I've worked around the limitation by using CSS in the block's editor stylesheet to hide all of the controls that would allow the user to move blocks around or insert new ones. Not ideal, obviously, but works for me for now.

Edit for clarity:
In the return value of my script's edit function:

<div className="slide-content">
  <InnerBlocks
    template={[
      ['core/heading', { placeholder: 'Slide heading...', level: 2, className: 'slide-title' }],
      ['core/paragraph', { placeholder: 'Slide content...', className: 'slide-text' }],
      ['custom/button', { text: 'Read More', btnClass: 'btn-filled', className: 'btn-lg' }]
    ]}
    // templateLock="all"
  />
</div>

And in the SASS file that produces the editor CSS:

.slide-content {
  .editor-block-list__insertion-point,
  .editor-block-mover,
  .editor-default-block-appender {
    display: none !important;
  }
}

@aduth
Copy link
Member

aduth commented Mar 27, 2019

@jorgefilipecosta Given the relation to templateLock, do you have a sense whether #14003 might resolve this?

@jorgefilipecosta
Copy link
Member

Hi @aduth,
I don't think #14003 will solve this problem right away.
#14003 ignores an action if it is not allowed. Here it looks like the bug is that when we have templateLock a block replacement function is not passed somewhere and that function is called anyway e.g: to perform a replace during a copy paste.
I think with #14003 in we can simply pass the function anyway knowing that even if dispatches an action, the action is ignored if not allowed. I will explore this option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Paragraph Affects the Paragraph Block [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P Needs Testing Needs further testing to be confirmed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants