-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Plugin sorting via priority property in registerPlugin #16384
base: trunk
Are you sure you want to change the base?
Conversation
This was broken out based on comments from @youknowriad on #13361 |
@youknowriad have you had a chance to think on this any further? Happy to make any changes as needed. |
be7bf0d
to
31be67b
Compare
…orts the registered plugins by priority before rendering them in PluginArea
…orts the registered plugins by priority before rendering them in PluginArea
31be67b
to
247a1a2
Compare
Adding in what @youknowriad mentioned during the core editor meeting on the 11th September: |
Based on comments in the last #core-editor meeting, I feel I need to better explain this PR. I have created a new issue #18064 to track the intent. @mcsf commented:
The items that would be affected by this change are very much visually based. They appear in a certain locations of the admin - ie. Menu Items and sidebar panels
I want to make it clear, that this PR does not affect how a SlotFill is rendered and it doesn't interact with the SlotFill system in any way. It simply controls the order in which plugins( that contain SlotFIlls ) are rendered inside the |
@ryanwelcher care to resolve the merge conflicts so @etoledom could smoke test this on mobile? |
@etoledom will you please smoke test this on mobile and report back your findings? |
@etoledom any chance you've been able to smoke test this on mobile? |
@ryanwelcher, @jeffpaul, apologies for the delay here! @etoledom isn't working on Gutenberg Mobile at the moment but has asked those of us currently on the team to take a look. I plan to take a look tomorrow. As the PR hasn't been updated since May 2021, I'd be grateful if you had a chance to update with the latest changes from |
@ryanwelcher, @jeffpaul, I tested this locally on mobile by going through some of the main writing flows e.g. adding and editing multiple third-party blocks, uploading images, general formatting, etc. I didn't spot any regressions, and wouldn't expect any as we don't appear to use the To test this, I had to update from |
@SiobhyB thanks for following up, I've been AFK for the holidays but will take a look at this shortly! |
I came looking for this functionality as a way to present a My reading of the code and the default 10 makes me think positioning within current panels would not be possible. Thought it was worth mentioning it now in case it can be added to this PR / there is anythning that can be changed in this PR to make it easier to implement in the future. |
@ryanwelcher would you be able to update this PR with the last changes from |
Does anyone know if there's a workaround for this? |
Not that I am aware of. |
Description
As is stands now, there is no way to control the order of the items being rendered in Slots. This PR adds a new
priority
property to the settings object that is passed toregisterPlugin
. This property is optional and has a default value of 10. I chose 10 as that is the default priority for Hooks and familiar to most WordPress developers and so that we can move items ahead of the default position without using negative numbers.The approach adds the
priority
property when the plugin is being registered and then usessortBy
to sort the plugins before they are rendered inside the<PluginArea />
component.How has this been tested?
This has been tested locally and using the unit and e2e tests.
Types of changes
New feature (non-breaking change which adds functionality)
Checklist: