react-devtools icon indicating copy to clipboard operation
react-devtools copied to clipboard

"Inspect in react" context menu

Open tnrich opened this issue 10 years ago • 9 comments

I don't know if this would be possible, but it would be awesome if there were a way to select a component on the page and have it jump to that component in the tools a la the normal chrome "inspect element": image

Imagine if there was an "inspect in react" option!

tnrich avatar Feb 04 '16 21:02 tnrich

I don't believe this is possible, but if you inspect element and then switch to the React tab, it should select the right component automatically!

sophiebits avatar Feb 04 '16 21:02 sophiebits

Extensions can add items to the context menu, and I think I remember @sebmarkbage opting not to do it for the original extension to avoid clutter. but I'd be open to it -- would certainly cut two steps down to one

jaredly avatar Feb 04 '16 22:02 jaredly

I don't want to show it on non-React pages but if we can do it without that then I'm in favor.

sophiebits avatar Feb 04 '16 22:02 sophiebits

Hey @jaredly thanks for the info about switching tabs to inspect the element. That alone is a big help! I'd still be in favor an "inspect in react" option, but I don't think it is as urgent now that I know the other method. Thanks again!

tnrich avatar Feb 04 '16 22:02 tnrich

I don't believe either opening devtools from background or content scripts, nor opening a specific panel programmatically (say when devtools is already open) are possible at this time. I looked through the chrome.devtools APIs and couldn't find anything.

I don't want to show it on non-React pages but if we can do it without that then I'm in favor.

Having it only on React pages should be easy: you'd listen on tab changes and add or remove the context menu item based on the page. But that seems moot from what I can tell.

I'd be happy to be proven wrong though :smile:

edit: granted, I looked at Chrome only. Maybe other browsers let you do it…

Timothee avatar Feb 15 '16 03:02 Timothee

I know Redux DevTools does add something to the context menu (see screenshot below), but I don't think it's quite the same thing being asked for here.

That said, I really want this feature.

Redux DevTools context menu:

screen shot 2016-04-26 at 12 29 37 pm

jrnail23 avatar Apr 26 '16 16:04 jrnail23

@jrnail23 I just checked it out and it's not the same thing indeed. All the five options displayed above open a separate browser window, not a panel in Chrome DevTools. ("Open in a chrome panel" made me hopeful but I checked the source code as well, and it just opens a window)

Timothee avatar Apr 26 '16 17:04 Timothee

Closing as it doesn't seem possible. Let me know if I'm wrong and we'll reopen.

gaearon avatar Feb 15 '17 18:02 gaearon

If you're open for a good ol' hack, this has been working for me 😁

demo

Prereq: Better Touch Tool ❤️

screen shot 2017-10-13 at 2 49 40 pm
  1. Select [or add] Chrome to the application pane on the left

  2. Select desired trigger (for me in the above image, it's keyboard)

  3. Set trigger (for me cmd+shift+option+r) to trigger context menu item

  4. In resultant input box, do this: screen shot 2017-10-13 at 2 52 13 pm

  5. Attach 2 additional actions by clicking "Attach additional action" button on the bottom right

  6. Set 1st additional action -> delay by 0.6 (might vary depending on your computer)

  7. Set 2nd additional action -> cmd + ]

  8. Profit

crimsonsunset avatar Oct 13 '17 18:10 crimsonsunset