-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Widgets editor - prevent creation of multiple reference widgets #25494
Comments
I guess we need to decide how we want |
Is the idea that If so, I'm not sure Consider a block where all the attributes can be changed from the values set initially by the variation, it'd be impossible to tell it was originally created using a variation. Probably need to create something ad-hoc for widgets that checks for instances of reference widgets in the content and then unregisters the matching variations. |
This unfortunately wouldn't cover block duplication or copying&pasting. |
https://github.com/WordPress/gutenberg/blob/master/packages/blocks/src/store/selectors.js#L212-L225 The way I see it is that we have three options:
1 and 2 could turn into rather large refactoring tasks, and while not impossible, I'm curious if 3 would work for us here. |
#25741 attempts to register each reference widget as a separate block. |
Oh, good point. Multiple blocks makes sense, it's the way widgets used to work so there's precedence. |
Creating blocks has several implications and for me sounds too heavy-handed to solve this particular issue which seems rather smallish. I fear the unintended consequences. |
@youknowriad although I had a feeling this might be the concern, I don't have a good understanding of all the implications - would you mind elaborating? Also, I would appreciate your input about possible alternatives.
The options I considered were:
I don't like any of these options and I wasn't able to come up with anything better than registering one block per widget. I would really appreciate your thoughts and ideas.
Just noting that we would have granular control over all |
Looking at all the options, I still think multiple blocks is the easiest and safest option. Although it'd be great to make supports: {
multiple: [ 'widgetName' ]
} |
After further discussion @youknowriad reaffirmed that registering a block per reference widget is not the right tool for the job and suggested an alternative of simply displaying an error message in duplicate instances. #26148 is an attempt at that. The API part of the equation is a different question. I can see two ways to proceed here:
|
Footgun? How so? The example you gave doesn't look like much of a footgun other than it overwrites the content in other instances of the widget. This could easily be addressed with a simple warning message. "Warning: the edits you make will take effect in all instances of the Marquee widget." If you have a better example, please share it, but I'm yet to see any examples of multiple reference widgets causing side effects any more serious than that. That said, even if you do deem #26148 to solve this, then it still calls #25371 into question. #25371 heavy-handedly sacrificed an important feature largely on the grounds of avoiding this "footgun" that #26148 now concedes can't be avoided. |
Describe the bug
As discussed in #24905, it is possible to create multiple reference widgets by leveraging multiple legacy widget blocks. There should only ever be at most one instance of any reference widget. Unfortunately
supports.multiple=false
only works for the block, not for it's variations.The text was updated successfully, but these errors were encountered: