-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Performance: Remove is-typing
root class
#32567
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,25 +27,20 @@ export const IntersectionObserver = createContext(); | |
|
||
function Root( { className, children } ) { | ||
const isLargeViewport = useViewportMatch( 'medium' ); | ||
const { | ||
isTyping, | ||
isOutlineMode, | ||
isFocusMode, | ||
isNavigationMode, | ||
} = useSelect( ( select ) => { | ||
const { | ||
isTyping: _isTyping, | ||
getSettings, | ||
isNavigationMode: _isNavigationMode, | ||
} = select( blockEditorStore ); | ||
const { outlineMode, focusMode } = getSettings(); | ||
return { | ||
isTyping: _isTyping(), | ||
isOutlineMode: outlineMode, | ||
isFocusMode: focusMode, | ||
isNavigationMode: _isNavigationMode(), | ||
}; | ||
}, [] ); | ||
const { isOutlineMode, isFocusMode, isNavigationMode } = useSelect( | ||
( select ) => { | ||
const { getSettings, isNavigationMode: _isNavigationMode } = select( | ||
blockEditorStore | ||
); | ||
const { outlineMode, focusMode } = getSettings(); | ||
return { | ||
isOutlineMode: outlineMode, | ||
isFocusMode: focusMode, | ||
isNavigationMode: _isNavigationMode(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, it seems really annoying that all blocks have to re-render if we simply want to toggle any of these modes above and add a class. :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💯 though hopefully these have less impact since the modes should be toggled less often 🤞 |
||
}; | ||
}, | ||
[] | ||
); | ||
return ( | ||
<div | ||
ref={ useMergeRefs( [ | ||
|
@@ -57,7 +52,6 @@ function Root( { className, children } ) { | |
'block-editor-block-list__layout is-root-container', | ||
className, | ||
{ | ||
'is-typing': isTyping, | ||
'is-outline-mode': isOutlineMode, | ||
'is-focus-mode': isFocusMode && isLargeViewport, | ||
'is-navigate-mode': isNavigationMode, | ||
|
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.
Do you think we should move this to
useBlockProps
instead of here (the leaf place where the classname is applied)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.
Oh good catch,
useBlockClassNames
felt like a better fit, so I moved that in 71d7488There 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.
🤔 the class could maybe use a better name, but I'd like to decouple it from
is-typing
so we can apply it only the situations we need it for.