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: Add the border width on initial color change for border #69112

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

hbhalodia
Copy link
Contributor

@hbhalodia hbhalodia commented Feb 10, 2025

What?

Fixes: #69094

  • PR adds the condition of undefined on initial render to set the width to 1px for border, if user adds/changes the color before explicitly setting the width.

Why?

How?

  • PR adds the undefined condition with the 0 width check.

Testing Instructions

  1. Open any page/post.
  2. Add any paragraph.
  3. Go to inspector control and enable border.
  4. Set the border color first, you would notice it would also add 1px width for border.

Testing Instructions for Keyboard

  • None

Screenshots or screencast

BorderFix.mov

@hbhalodia hbhalodia self-assigned this Feb 10, 2025
@hbhalodia hbhalodia marked this pull request as ready for review February 10, 2025 05:29
@hbhalodia hbhalodia requested a review from ajitbohra as a code owner February 10, 2025 05:29
Copy link

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Technical Prototype, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core, Gutenberg Plugin.
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

Copy link

github-actions bot commented Feb 10, 2025

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: hbhalodia <[email protected]>
Co-authored-by: coder-rancho <[email protected]>
Co-authored-by: viralsampat-multidots <[email protected]>

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

const hasZeroWidth = widthValue === 0;
// If widthValue is 0, or on initial render we have width undefined.
// Need to set width to `1px`, if we change color first before adding border width.
const hasZeroWidth = widthValue === 0 || undefined === widthValue;

Choose a reason for hiding this comment

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

Use YODA condition:

Suggested change
const hasZeroWidth = widthValue === 0 || undefined === widthValue;
const hasZeroWidth = 0 === widthValue || undefined === widthValue;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @coder-rancho, Thanks for pointing this out, but new coding standards proposes not to use Yoda Conditions. The codebase have bunch of files that are not using Yoda conditions. I would update the PR if core team want's to use Yoda condition here.

Thank You,

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.

Gutenberg border block setting should be working properly.
2 participants