pastelsky / tsdocs

Browse type documentation for JS libraries
https://tsdocs.dev
MIT License
1.13k stars 25 forks source link

feat: make Home/End keys usable in the search box #17

Closed rvbsm closed 11 months ago

rvbsm commented 11 months ago

Closing #3.

Also, I think that input's onKeyDown can be moved to Downshift's onKeyDown inside getInputProps, according to the docs.

{...getInputProps({
  onKeyDown: (event) => {
    // prevent key hijack by typedoc search
    // https://github.com/pastelsky/tsdocs/issues/2
    event.stopPropagation();
    ...
  }
})}

Didn't test it however

pastelsky commented 11 months ago

Thanks for the PR — but I don't have a way to validate this unfortunately.

Do you think you could add a quick screengrab? Should be good to go after.

rvbsm commented 11 months ago

Using both getInputProps#onKeyDown and onKeyDown wouldn't work because input's onKeyDown will override getInputProps#onKeyDown. So there are two workarounds:

Which option would be better, in your opinion? I've tested that both options work the same.

Do you think you could add a quick screengrab?

Yes, here

https://github.com/pastelsky/tsdocs/assets/39232658/ea2b9f04-fe77-4efa-bde6-9c850a63562b

pastelsky commented 11 months ago

move event.stopPropagation() to getInputProps#onKeyDown; This would be ideal if this doesn't have any other side effects.

Also, thanks for the video!

rvbsm commented 11 months ago

Seems to be done.

pastelsky commented 11 months ago

This is good, thanks a bunch. Happy holidays!

rvbsm commented 11 months ago

Happy holidays!

Happy holidays!