[6.x] Fix fieldtype picker showing wrong list after switching blueprint modes - #14919
Merged
Conversation
Key the shared fieldtype cache on the blueprint mode so form and regular blueprints refetch the correct list instead of reusing whichever loaded first. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request fixes an issue where the fieldtype picker shows the wrong list of fieldtypes after switching between a form blueprint and a regular blueprint (until a full page reload).
This was happening because the picker caches its fieldtype list in a module-level singleton shared across every instance, but the two modes request different lists — regular blueprints fetch all selectable fieldtypes, while form blueprints fetch a smaller list that respects
Fieldtype::makeUnselectableInForms(). Since the cache was only checked for "is it an array?", the first picker to load won, and every later picker early-returned regardless of its blueprint mode. Reloading fixed it because the module state reset.This PR fixes it by keying the cache on the blueprint mode. The cache now stores
{ forms, data }and is only treated as loaded when the cached mode matches the current picker's mode, otherwise it refetches the correct list. Cross-picker caching is preserved within a mode.FWIW: I've removed
isFormBlueprinton theforms-2branch because forms won't be using blueprints with the new form builder / form fieldtypes system.Fixes #14903