Lazy option on block builder#19867
Open
KianAcquoy wants to merge 9 commits into
Open
Conversation
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.
Solves: #5401
Description
Builder components with many items are slow to render because every block's schema is evaluated and sent to the browser on initial page load, regardless of whether the user ever opens those items.
This PR adds opt-in lazy loading to the
Buildercomponent. Calling->lazy()makes the builder collapsible and starts every item collapsed. Each item renders only its header and a loading placeholder on first load. When the user expands an item, a Livewire call triggersloadItem, which renders the block's schema and injects it into the page.State is always kept in the parent Livewire data array, values survive collapse/expand cycles and page reloads. Validation still runs against unloaded items: if a required field is missing in a collapsed block, the item is automatically expanded and loaded on submit.
Per-block opt-out:
Block::make(...)->lazy(false)on an individual block forces it to render eagerly even inside a lazy builder.Unload on collapse:
->lazy(unloadOnCollapse: true)removes a block's schema from the DOM when the user collapses it again.Visual changes
Instead of instantly opening the collapsed block, it will open with a loading state.

Functional changes
composer cscommand.