Skip to content
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

[DevTools] Make Functions Clickable to Jump to Definition #30769

Merged
merged 3 commits into from
Aug 22, 2024

Conversation

sebmarkbage
Copy link
Collaborator

Currently you can jump to definition of a function by right clicking through the context menu. However, it's pretty difficult to discover. This makes the functions clickable to jump to definition - like links.

This uses the same styling as we do for links (which are btw only clickable if they're not editable). Including cursor: pointer.

I added a background on hover which follows the same pattern as the owners list.

I also dropped the ƒ prefix when displaying functions. This is a cute short cut and there's precedence in how Chrome prints functions in the console if the function's toString would've had a function prefix like if it was a function declaration or expression. It does not do this for arrow functions or object methods.

Elsewhere in the JS ecosystem this isn't really used anywhere. It invites more questions than it answers.

The parenthesis and curlies are enough. There's no ambiguity here since strings have quotations. It looks better with just its object method form. Keeping it simple seems best. To my eyes this flows better because I'm used to looking at function syntax but not weird "f"s.

Before:

Screenshot 2024-08-20 at 11 55 09 PM

After:
Screenshot 2024-08-20 at 11 46 01 PM

After (Hover):
Screenshot 2024-08-20 at 11 46 31 PM

This is a cute short cut and there's precedence in how Chrome prints functions
in the console *if* the function's toString would've had a function prefix
like if it was a function declaration or expression. It does not do this
for arrow functions or object methods.

Elsewhere in the JS ecosystem this isn't really used anywhere.
It invites more questions than it answers.

The parenthesis and curlies are enough. There's no ambiguity here since
strings have quotations. It looks better with just its object method form.

Keeping it simple seems best.
While this might not be an arrow function it's a common enough annotation
for an unnamed function that people would get it.
Hover state makes it a little clearer that it's clickable and follows the
pattern of the owner list.
Copy link

vercel bot commented Aug 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 21, 2024 4:00am

Copy link
Collaborator

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To my eyes this flows better because I'm used to looking at function syntax but not weird "f"s.

Agreed. Just f would also beg the question if we should add async if it is a real async function

Also 👍🏻 for making it a simple link instead of hiding it behind a context menu. That's also why I skipped reviewing #30786 earlier because I simply didn't know this functionality existed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants