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

[ Navigation block ] Remove unnecessary white spaces. #67999

Closed

Conversation

kurudrive
Copy link
Contributor

@kurudrive kurudrive commented Dec 15, 2024

What?

Remove unnecessary white spaces from navigation block's class.

Why?

The navigation block's class name contains unnecessary spaces.

スクリーンショット 2024-12-15 15 21 00

How?

Delete space ( add .trim(); )

Testing Instructions

  1. npm run build
  2. Please check HTML of the navigation block

Screenshots or screencast

After
スクリーンショット 2024-12-15 15 39 21

@kurudrive kurudrive marked this pull request as ready for review December 15, 2024 07:03
Copy link

github-actions bot commented Dec 15, 2024

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: kurudrive <[email protected]>
Co-authored-by: talldan <[email protected]>
Co-authored-by: luisherranz <[email protected]>

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

@t-hamano t-hamano added [Type] Code Quality Issues or PRs that relate to code quality [Block] Navigation Affects the Navigation Block labels Dec 16, 2024
@talldan
Copy link
Contributor

talldan commented Dec 17, 2024

Thanks for the contribution. From what I can tell this change doesn't seem to fix the issue. I think the extra space come from the Interactivity API's data-wp-class directive, which is used on that element:

data-wp-class--has-modal-open="state.isMenuOpen"
data-wp-class--is-menu-open="state.isMenuOpen"

It seems like a very minor issue, but I'll cc @luisherranz, just in case it's a quick one to fix.

@luisherranz
Copy link
Member

Maybe it's the way we are formatting the directives in PHP using line breaks instead of spaces?

@talldan
Copy link
Contributor

talldan commented Dec 20, 2024

Actually, I take it back, sorry for the incorrect ping @luisherranz . It is caused by the navigation block's code. I made a PR for it - #68161. I'll close this one.

Possibly there is still an issue in the interactivity API, hard for me to say. On first process of the directive it trims the class attribute and removes the extra space the nav block was outputting, and assigns the trimmed value back to element.props.class:

element.props.class = currentClass
.replace( classFinder, ' ' )
.trim();

Then on clicking the button the extra space seems to come back again via the currentClass variable:

element.props.class = currentClass
? `${ currentClass } ${ className }`
: className;

It seems like element.props.class isn't updated properly that first time, or perhaps some other code sets it back to the original value.

Anyway, after calling this low priority I've spent time debugging it now 🤦

@talldan talldan closed this Dec 20, 2024
@kurudrive
Copy link
Contributor Author

@talldan Thank you for checking and addressing the issue ( ̄人 ̄)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation Block [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants