-
Notifications
You must be signed in to change notification settings - Fork 217
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
area/ui: Add a preference to render function names from the right #5382
base: main
Are you sure you want to change the base?
Conversation
🤖 Meticulous spotted visual differences in 158 of 223 screens tested: view and approve differences detected. Meticulous simulated ~5 hours of user flows against your PR. Last updated for commit 70275cb. This comment will update as new commits are pushed. |
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.
Just a minor feedback, looks great otherwise!
USER_PREFERENCES.SHOW_FUNCTION_NAME_FROM_LEFT.key | ||
); | ||
|
||
useEffect(() => { |
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 useState
+ useEffect
combo can be replaced with a single useMemo
that returns the text that can be used below to render.
Technically, useState
+ useEffect
method has to render the component twice before it renders the expected output while the useMemo
approach would do it in a single render. Not a biggie, but it improves the readability as well.
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.
good catch, i'll make that change.
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.
hmm so I made changes based on the feedback above to now use useMemo.
const displayText = useMemo(() => {
const textElement = textRef.current;
if (textElement === null) return text;
return showFunctionNameFromLeft ? text : calculateTruncatedText(text, textElement, width);
}, [text, width, showFunctionNameFromLeft, textRef]);
but with this new change we don't get to see the truncated text when it should be shown.
I'm assuming this is related to the usage of the textRef
ref and the fact that useMemo is running before the ref is attached to the DOM, therefore the initial render will always have textRef.current
as null, and the memoization is preventing subsequent updates.
This adds a new preference to determine if long function names should be displayed from the left or right hand side. By default it is set to true/checked.
This new preference aims to solve the issue where long function names in the icicle graph are shortened due to the stack's width, and you only see the LHS of the function name.
When the preference is unchecked/set to false, and the
rect
that displays the function name is not wide enough to show the entire name, then we just show the right hand side of the function name.Checked
Unchecked