-
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
Editor: Improve render performance (scrolling and typing) #23568
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a208396
Improve scroll rendering for editor
e1bc948
Merge branch 'master' into try/editor-improve-render-performance
95bf5b5
Improve layout rendering on interaction (e.g. typing)
0b68b67
Merge branch 'master' into try/editor-improve-render-performance
abdf617
Remove unused styles
d30e5cb
Fix accidental Toolbar merge issue
06efcdc
Merge branch 'master' into try/editor-improve-render-performance
c2ae98e
Merge branch 'master' into try/editor-improve-render-performance
1c907bc
Merge branch 'master' into try/editor-improve-render-performance
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
40 changes: 40 additions & 0 deletions
40
packages/interface/src/components/interface-skeleton/utils.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useEffect } from '@wordpress/element'; | ||
import { useResizeObserver } from '@wordpress/compose'; | ||
|
||
const SKELETON_BODY_HEIGHT_CSS_PROP = '--wp-editor--body-height'; | ||
|
||
export function useObserveInterfaceHeight( { ref } ) { | ||
const [ resizeListener, sizes ] = useResizeObserver(); | ||
|
||
/* | ||
* This calculates and sets a body height for the inner | ||
* content, sidebar, and complementary areas. This improves performance, | ||
* as we can avoid having the browser (re)calculate layout values on | ||
* interaction (e.g. typing). | ||
*/ | ||
const setBodyHeightValue = () => { | ||
const bodyHeight = ref.current?.clientHeight; | ||
if ( bodyHeight ) { | ||
const nextHeight = window.innerHeight - bodyHeight; | ||
// We're using calc with a 100vh offset improve responsiveness | ||
// when resizing the browser's height. Using a fixed pixel value | ||
// directly may result in double scrollbar flickering. | ||
const nextHeightValue = `calc(100vh - ${ nextHeight }px)`; | ||
|
||
// We'll set the value as a custom CSS variable. | ||
// The inner content, sidebar, and complementary areas are | ||
// "subscribed" to this value using CSS. | ||
document.documentElement.style.setProperty( | ||
SKELETON_BODY_HEIGHT_CSS_PROP, | ||
nextHeightValue | ||
); | ||
} | ||
}; | ||
|
||
useEffect( setBodyHeightValue, [ sizes.height ] ); | ||
|
||
return { resizeListener }; | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this slot was not rendered her for a valid reason. Otherwise, it just duplicated the slot that is above it. cc @ellatrix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@youknowriad Hmm! Interesting.. I wasn't aware of that !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be rendered in the content scroll container, because when you scroll while the pointer is over the toolbar, the content still needs to scroll.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should have commented here 😅
There might be other reasons I'm forgetting.