rafgraph / react-router-hash-link

Hash link scroll functionality for React Router
https://react-router-hash-link.rafgraph.dev
MIT License
732 stars 62 forks source link

Make it possible to opt out of focus handling #90

Open Haraldson opened 2 years ago

Haraldson commented 2 years ago

Possible bonus: Regard contenteditables as interactive elements, but I understand if you don’t want this as part of the same PR, or have considered this before and concluded that it’s best to leave them out.

I’m not entirely sure about the flow of arguments here and whether it could be simplified or flow in a more natural way, but it seems to be working as intended.

Fixes #89

Haraldson commented 2 years ago

Did a lil’ self-review and noticed my brain did a derp. This code will work as intended in my use case, or for people who explicitly defined the prop, but not for anyone else.

The JavaScript flavor here seems fairly modern, but I don’t see any default values in function signatures, null-coalescing operators or similar. What’s your preferred way of defining default values, @rafgraph?

rafgraph commented 2 years ago

Thanks for the PR. Generally looks good, thanks for contenteditable addition.

One important change, the preventFocusHandling prop should be tracked as a singleton (like hashFragment on line 5) and not passed to the functions.

Haraldson commented 2 years ago

I hope and think that should do it, @rafgraph!