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: Highlighted heading block breaks when moved into a group block #68342

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

nani-samireddy
Copy link

@nani-samireddy nani-samireddy commented Dec 27, 2024

Closes #56025

What?

As mentioned in #56025, When we add a heading or p tag with a color highlight into a group block. Then It break on the initial render.

Why?

  • In the Text-Color Component on this Line, We are using the contentRef.current when we drop heading or p. We might be accessing the element before it is fully rendered. Which gives an undefined value and that undefined is passed down in the functions leading to this error.

How?

  • As the contentRef.current is passed down to the functions to calculate styles, Adding a check in the useMemo callback to only call the fillComputedColors function if we have a ref.

Testing Instructions

  1. Open the block editor.
  2. Add a Heading/Paragraph
  3. Add a background highlight color
  4. Add group block
  5. And drag and drop the Heading/Paragraph into the group block

Testing Instructions for Keyboard

Screenshots or screencast

Before

before.mov

After

after.mov

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Dec 27, 2024
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @nani-samireddy! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@nani-samireddy nani-samireddy marked this pull request as ready for review December 27, 2024 09:00
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: nani-samireddy <nanisamireddy@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@up1512001 up1512001 added [Type] Bug An existing feature does not function as intended [Feature] Drag and Drop Drag and drop functionality when working with blocks labels Dec 27, 2024
@up1512001 up1512001 requested a review from t-hamano December 27, 2024 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Drag and Drop Drag and drop functionality when working with blocks First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Highlighted heading block breaks when moved into a group block
2 participants