-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Calendar: Prevent attribute styles/classes from printing twice #43653
Open
ndiego
wants to merge
1
commit into
WordPress:trunk
Choose a base branch
from
ndiego:fix/attributes-printing-twice-in-calender-block
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that if we remove the
attributes
prop from theServerSideRender
component, we would not be able to dynamically generate styles and markup based on attirbutes, including block support such as Dimension.For example, #42029 uses attributes to apply a color to a table tag inside a calendar block.
I have addressed my concerns and suggestions in my comments here, but I think we should have a little more discussion about the policy for addressing the addition of support for blocks using the
ServiersideRender
component.Also, as mentioned within the comments above, there are five blocks that use the ServersideRender component, and duplicate class names might need to be resolved in all of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good questions, thanks for opening the PR @ndiego and for the ideas here @t-hamano!
I was wondering if another option rather than preventing passing
attributes
to theServerSideRender
component would be to strip thestyle
key from the rest expansion of...useBlockProps()
on the wrapperdiv
? That way we might be able to defer to theServerSideRender
for all block style output when we're using the server side rendering in the editor.I haven't tried it, and there could be edge cases with that idea, but just thought I'd raise it in case it seems like another viable option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a semi-related PR that selectively removed the test-decoration for the post comments count block's editor rendering (#43497) — while that one was to do with preventing style output that affects the placeholder state, we might be able to use a similar approach in this (and other blocks that use
ServerSideRender
) to skip the style output at the wrapperdiv
level 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ndiego
@andrewserong
I raised the new approach in my comment here in reference to #43497. I would love to hear your thoughts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the discussion that took place in comment #43243, I think the following might be a good approach.
Don't pass
margin
andpadding
with block support toServersideRender
component (it is simpler to remove spacing all together than to limit it to margin alone, which simplifies the code)As for
className
, only give it to the block wrapperdiv
, as per this PR policyHere is an example code:
I think we shuldn't use
omit
, etc, because I found that #17025 is trying to move away from Lodash.This code also takes into account the spacing support that will be added in #43654. However, we will need to brush up on this code for color support, which will be added in #42029.
@ndiego
@andrewserong
We are looking forward to your advice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback @t-hamano, sorry for the delay, been tied up with WCUS prep. I will take a look at this approach this weekend!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just closing the loop on the above comment for the
omit
usage - #17025 has landed and we're no longer using Lodash in the entire repository.