Skip to content

Commit d3f800d

Browse files
authored
[DevTools] Style clickable Owner components with angle brackets and bold (#34096)
We have two type of links that appear next to each other now. One type of link jumps to a Component instance in the DevTools. The other opens a source location - e.g. in your editor. This clarifies that something will jump to the Component instance by marking it as bold and using angle brackets around the name. This can be seen in the "rendered by" list of owner as well as in the async stack traces when the stack was in a different owner than the one currently selected. <img width="516" height="387" alt="Screenshot 2025-08-03 at 11 27 38 PM" src="https://github.com/user-attachments/assets/5da50262-1e74-4e46-a6f8-96b4c1e4db31" /> The idea is to connect this styling to the owner stacks using `createTask` where this same pattern occurs (albeit the task name is not clickable): <img width="454" height="188" alt="Screenshot 2025-08-03 at 11 23 45 PM" src="https://github.com/user-attachments/assets/81a55c8f-963a-4fda-846a-97f49ef0c469" /> In fact, I was going to add the stack traces to the "rendered by" list to give the ability to jump to the JSX location in the owner stack so that it becomes this same view.
1 parent 8e3db09 commit d3f800d

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

packages/react-devtools-inline/__tests__/__e2e__/components.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ test.describe('Components', () => {
5252

5353
test('Should allow elements to be inspected', async () => {
5454
// Select the first list item in DevTools.
55-
await devToolsUtils.selectElement(page, 'ListItem', 'List\nApp');
55+
await devToolsUtils.selectElement(page, 'ListItem', '<List>\n<App>');
5656

5757
// Prop names/values may not be editable based on the React version.
5858
// If they're not editable, make sure they degrade gracefully
@@ -119,7 +119,7 @@ test.describe('Components', () => {
119119
runOnlyForReactRange('>=16.8');
120120

121121
// Select the first list item in DevTools.
122-
await devToolsUtils.selectElement(page, 'ListItem', 'List\nApp', true);
122+
await devToolsUtils.selectElement(page, 'ListItem', '<List>\n<App>', true);
123123

124124
// Then read the inspected values.
125125
const sourceText = await page.evaluate(() => {
@@ -142,7 +142,7 @@ test.describe('Components', () => {
142142
runOnlyForReactRange('>=16.8');
143143

144144
// Select the first list item in DevTools.
145-
await devToolsUtils.selectElement(page, 'ListItem', 'List\nApp');
145+
await devToolsUtils.selectElement(page, 'ListItem', '<List>\n<App>');
146146

147147
// Then edit the label prop.
148148
await page.evaluate(() => {
@@ -177,7 +177,7 @@ test.describe('Components', () => {
177177
runOnlyForReactRange('>=16.8');
178178

179179
// Select the List component DevTools.
180-
await devToolsUtils.selectElement(page, 'List', 'App');
180+
await devToolsUtils.selectElement(page, 'List', '<App>');
181181

182182
// Then click to load and parse hook names.
183183
await devToolsUtils.clickButton(page, 'LoadHookNamesButton');

packages/react-devtools-shared/src/devtools/views/Components/OwnerView.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
color: var(--color-component-name);
33
font-family: var(--font-family-monospace);
44
font-size: var(--font-size-monospace-normal);
5+
font-weight: bold;
56
white-space: nowrap;
67
overflow: hidden;
78
text-overflow: ellipsis;

packages/react-devtools-shared/src/devtools/views/Components/OwnerView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default function OwnerView({
5959
<span
6060
className={`${styles.Owner} ${isInStore ? '' : styles.NotInStore}`}
6161
title={displayName}>
62-
{displayName}
62+
{'<' + displayName + '>'}
6363
</span>
6464

6565
<ElementBadges

0 commit comments

Comments
 (0)