-
Notifications
You must be signed in to change notification settings - Fork 55
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
Components tree changes to improve HOCs and browsing deep trees #295
Conversation
This reverts commit 33432b0.
@@ -310,7 +307,6 @@ export default function Tree(props: Props) { | |||
itemCount={numElements} | |||
itemData={itemData} | |||
itemSize={lineHeight} | |||
overscanCount={3} |
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.
Why? I added this because of visual artifacts on fast scrolling. I don’t think it’s solved yet. Maybe we need to look into why it happens though.
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.
Couple of reasons:
- I don't think overscan actually helps much with artifacts. It only helps with the first paint or two after a fast scroll. After that, react-window is racing to keep up with a passive "scroll" event regardless.
- With dynamic indentation, I didn't want the size of hidden/offscreen rows visually impacting the indentation size too much, because it felt a bit awkward in some cases.
I don't feel very strongly about this, but it did seem like a positive change.
Remove selected guideline in favor of background color for selected subtree. Add badges in grid format to selected elements prop panel. Show badges beside owners list.
Okay, I think I'm done with this batch of changes. Code review and/or testing welcome if you're interested! |
A few things I've noticed:
|
This is important since we are caching element sizes by DOM (in a WeakMap). Toggling (as well as insertion/deletion) might otherwise break this in some cases.
I could not reproduce this, but conceptually I believe it was due to the fact that I am caching measurements per DOM item with a
No immediate ideas come to mind. Having tried several forms of animation and/or debouncing over the past few days, I think I've decided that I dislike them all- but maybe we can brainstorm this and come up with something this week.
Yeah, I see why this is not ideal, but I'm also not sure how to fix it given the constraints we're working under. Maybe we can brainstorm it some this week while you're in town. Although I also don't think it's a show-stopper, when compared to the previous horizontal scrolling. |
Few more thoughts:
|
This sounds potentially promising. Let's pair on it tomorrow.
Padding removed in 8261a3f. Should we want to add it back in a way that also scrolls out of view, I added an entry to the |
f713265 takes a shot at this! react-devtools-experimental/src/devtools/views/Components/Tree.js Lines 411 to 421 in f713265
Before0.5 pixel max0.25 pixel max |
Commit 78cf211 tries to address the concern of "jumping" in a more extreme way: We decrease indentation to fit wider/deeper trees, but we do not increase it again (unless the window resizes). I think this also helps with cases where clicking to collapse a row might otherwise jump horizontally beneath your cursor. |
I'm not too sure why someone would want to filter out HOC wrapped components. Though it might be nice to have an inverse filter option in the case that an engineer is working to clean them up. Or maybe even filter by HOC name so that it would be easy to find all occurrences of an HOC that a team might be wanting to remove? |
People have asked for this feature in the past.
Filters are exclusive/reductive. It was a conscious decision not to mix and match inclusive and exclusive filters because I thought it would result in a confusing UX. That being said, you could do what you're asking for (only showing HOCs) with an exclusive "name" filter of |
Great!
Sounds good! Also a great decision, supporting inclusive and exclusive is a nightmare. I've had to support it in the past, haha. |
76a141d
to
06b004b
Compare
… removed from selected highlight
1. Bugfix: Hide tree grouping/background coloring when inside of collapsed subtree. 2. Bugfix: Don't measure and udpate indentation when Components tab is hidden. 3. Tweak: Lower background color for selected subtree in light theme to increase contrast for text. 4. Tweak: Remove FB-specific displayName check/hack since we will address that by modifying the internal require JS transform.
As a result, paddings and sizes (e.g. tab bar heights) will also be impacted now by this preference. More importantly, Profile charts will also use the line height preference, so the 'comfortable' setting will hopefully make profiling data easier to read.
I'm going to roll forward with this. We can iterate on it more as needed. |
💯 🎉 |
As a relatively experienced react user where many of my projects have lots of react-redux connected components, I absolutely love the decision to hide HOCs. That being said, when I was a beginner just learning, I relied really heavily on (somewhat blindly) making changes and seeing what they did in devtools to learn how things worked. Are we worried that hiding HOCs from the tree might obscure what they really are to learners? (Is the fact that they exist in the tree even important information for users of HOCs or just an implementation detail?) |
HOCs are not hidden from the tree (unless you explicitly add a component filter to hide them). This PR just changes the way they are presented to (hopefully) be more readable. The same tree structure (HOC outside with decorated component inside) still exists. |
This PR introduces a drastically new UX behavior to the Componts tab: Horizontal scrolling is removed entirely in favor of dynamically changing indentation so that all rows fit within the viewport. The change also enabled me to simplify the DOM structure of each row in the tree, since most of the complexity before was only needed to support background color of overflowing rows.
The bulk of how that change works is outlined here:
react-devtools-experimental/src/devtools/views/Components/Tree.js
Lines 325 to 365 in 6b6e571
To support this change and avoid odd UI/UX interactions, I also made the following adjustments:
What does "dynamic indentation" mean?
Let's take a look at Twitter for an example. As we scroll deeper into the component tree, it's easy to get "lost" because of the empty horizontal space. After this change, scrolling deeper into the tree will cause the indentation size to be adjusted so the deepest/widest components fit fully within the viewport.
Here is a side by side before and after:
Remove HOCs from display names and show as badges
HOCs make component names longer and harder to parse. (They also require indentation to be compressed more aggressively.) This diff tries a new approach with them- removing the HOC portions of the display name and pulling them out into badges.
For example, here's what a really long HOC display name might look like before this change:
And here's what it looks like afterward:
There is one downside for this change: Search no longer finds matches based on the HOC portion of the display name (since that bit is parsed out). We could change the search behavior to also include HOCs if we think it's important, but I don't think it's necessary for now.
New HOC component filter
Since I've committed to identifying HOCs as display names that contain parenthesis, it seemed worth going one step further and adding a convenience HOC filter:
Replace indent lines with background color
Indent lines looked bad when combined with dynamic indentation:
The primary purpose these lines served is showing the hierarchy. I think we can achieve the same thing using background color to group descendants of the selected component.
Here is a side by side before and after:
Should we debounce/animate indentation changes?
I experimented with this (as can be seen in the commit history) but ultimately decided against it. It feels more natural and fluid for indentation to adjust as soon as new rows are added or removed. Initial feedback from the few people I shared an early build with seems to support this decision.
Why not truncate long display names as well?
There are two basic approaches to truncating long display names:
max-width: x%
). The downside of this is that browsers more aggressively truncate text that's near the right edge of its container. This means that names might be truncated in an extreme way as the tree gets deeper (e.g. "Foobar" might be truncated to "F..." unnecessarily).I think in most cases, long names are due to HOCs that get added to the display name of what they're wrapping. I think we may be able to address this problem separately, by pulling out the HOC portion of the name.