Editor: Prevent saving while a new taxonomy term is being created#78659
Editor: Prevent saving while a new taxonomy term is being created#78659Mamaduka wants to merge 3 commits into
Conversation
|
Size Change: +160 B (0%) Total Size: 8.13 MB 📦 View Changed
ℹ️ View Unchanged
|
|
Flaky tests detected in eb51bfe. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/26440561640
|
|
@Mamaduka Do you think this could be related to #77721, the flaky e2e test where the Cancel button becomes mysteriously disabled for a moment? I just inspected the latest trace, looked at Network requests (I only recently learned that the Playwright traces include that, too 🙂) and I see a POST request: where the payload is just |
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
@jsnajdr, that could be it. It looks like the call is coming from the |
Yes, it's caused by the RTC-related request to persist the CRDT document. Only these requests have the minimal I'm not sure whether we really want to persist the CRDT document at these somewhat random times. The code calls a read-only |
|
I agree, these calls are unexpected, and we should definitely do something about them. Unfortunately, my understanding of RTC internals is still very limited; we would need help from pros. cc @alecgeatches |
We chatted about it with @ellatrix the other day (save side effect every time we receive an entity) and she recommended to create it on the server. Allegedly someone managed to port Yjs to PHP 🙂 |
You can do anything with enough tokens these days :) @jsnajdr, is this good to merge? |
jsnajdr
left a comment
There was a problem hiding this comment.
Looks good 👍
We have two different mechanisms for preventing save:
lockPostSavingand theisPostSavingselector, where any component can imperatively disable save- the
isSavingNonPostEntityChangesselector which is also used to effectively lock saves, and is typically used together withisPostSavingLockedselector.
Could they possibly be unified into one in some way?
|
You're right, this should be fully handled via Something might've regressed, or it doesn't cover entity creation. I'll investigate. I like solving this without needing to sprinkle post-locking in consumer components. |
What?
Closes #78558.
In
FlatTermSelectorandHierarchicalTermSelector, wrap thesaveEntityRecordcall that creates a new term withlockPostSaving/lockPostAutosaving, releasing in.finally()once the request(s) settle.I've also updated
FlatTermSelectorto use the new recommendedStackcomponent.Why?
Both components update the post's term IDs only after the
POST /wp/v2/<taxonomy>request resolves. If the user clicked Publish/Save during that window, the post was saved with the pre-creation term IDs. The new term existed in the database but wasn't associated with the post until a second save. The race was reliably reproducible on slower sites where the create request takes a few seconds.Testing Instructions
Testing Instructions for Keyboard
Same.
Use of AI Tools
Assisted by Claude. Mostly for review.