-
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
Rich text: try removing store change on focus #48342
Conversation
Size Change: +198 B (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
Flaky tests detected in 83119aa. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4254673746
|
@@ -106,7 +110,7 @@ export function useInputRules( props ) { | |||
} | |||
|
|||
if ( __unstableAllowPrefixTransformations && inputRule ) { | |||
inputRule(); | |||
if ( inputRule() ) return; |
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 is probably not needed for this PR, but still good to return here.
@@ -86,9 +88,11 @@ export function useInputRules( props ) { | |||
} ); | |||
const block = transformation.transform( content ); | |||
|
|||
selectionChange( findSelection( [ block ] ) ); | |||
selectionChange( ...findSelection( [ block ] ) ); |
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.
The reason this fixes the failing test is because we preset selection in the store after replacing the input rule. So when the new block is created, the selection is already correct at the time of the focus event.
@@ -287,7 +287,6 @@ export function useInputAndSelection( props ) { | |||
end: index, | |||
activeFormats: EMPTY_ACTIVE_FORMATS, | |||
}; | |||
onSelectionChange( index, index ); |
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.
So this should be a small (maybe not noticeable) perf improvement, right?
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.
It's a huge improvement for focus
:
┌──────────────────────┬──────────────────────────────────────────┬──────────────┐
│ (index) │ fec7ea5acdf2c45e0ecbab96200aa945eb8daed5 │ trunk │
├──────────────────────┼──────────────────────────────────────────┼──────────────┤
│ focus │ '0.27 ms' │ '32.6 ms' │
│ minFocus │ '0.24 ms' │ '0.41 ms' │
│ maxFocus │ '0.36 ms' │ '48.82 ms' │
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.
Maybe we should update the metric though. It feels now that we should be computing "focus + selection change". It seems the time has moved to another event that we don't take into consideration in the metric itself?
d71b8a6
to
150f638
Compare
@@ -89,7 +89,7 @@ export default function getRectangleFromRange( range ) { | |||
// by adding a temporary text node with zero-width space to the range. | |||
// | |||
// See: https://stackoverflow.com/a/6847328/995445 | |||
if ( ! rect ) { | |||
if ( ! rect || rect.height === 0 ) { |
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.
Ranges set by Firefox might have 0 height (when it's collapsed on an empty string). This PR probably changes something where we're overriding the range set by Firefox, which is fine.
So as you can see in the performance metrics, simply adding It's still one
|
allDurations.reduce( ( acc, eventDurations ) => { | ||
return acc + sum( eventDurations ); | ||
}, 0 ) |
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 smells like it should be
sum( allDurations.map( sum ) )
No?
What?
See #44304. Just want to see e2e test results.
Why?
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast