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

Documentation could use more examples #359

Open
tannerhallman opened this issue Apr 30, 2020 · 17 comments
Open

Documentation could use more examples #359

tannerhallman opened this issue Apr 30, 2020 · 17 comments

Comments

@tannerhallman
Copy link

tannerhallman commented Apr 30, 2020

I created a dev.to post on a dropdown component where it uses the new recommended hook usePopper and I had an awfully hard time getting the example on the docs to work. If I was to PR some additions to the docs with a dropdown example, would that be accepted?

Code sandbox

@FezVrasta
Copy link
Member

Hi! Yes it'd be great, the documentation source code is at https://github.com/popperjs/website, please do let me know if you need any guidance.

@FezVrasta
Copy link
Member

FYI I'm getting a runtime error on your sandbox

@tannerhallman
Copy link
Author

Fixed it. Thank you. Some weird caching issue with old versions.

I'll get something PR'd this week.

@FezVrasta
Copy link
Member

FezVrasta commented Apr 30, 2020

It'd be cool if you followed the style we used for the vanilla tutorial https://popper.js.org/docs/v2/tutorial/

Ideally, a 1:1 transposition to React of that tutorial would be the best.

@tannerhallman
Copy link
Author

tannerhallman commented Apr 30, 2020 via email

@ghost
Copy link

ghost commented May 7, 2020

How do you actually use this with React? The vanilla JS docs are there but the React docs are lacking and it has a dead link. The repo itself has a demo folder with premade components so the usage is completely abstracted. Looking for more on the usePopper hook.

@ghost
Copy link

ghost commented May 7, 2020

Is there a way to close the popper when the user clicks outside?

@FezVrasta
Copy link
Member

@jibberishclient no, Popper is not a tooltip library.

@tannerhallman
Copy link
Author

tannerhallman commented May 7, 2020 via email

@ghost
Copy link

ghost commented May 7, 2020

Why is useState used instead of useRef?

@tannerhallman
Copy link
Author

tannerhallman commented May 7, 2020 via email

@ghost
Copy link

ghost commented May 7, 2020

I don't know why they use useState in the docs at all in the place of a ref lol. Complete nonsense.

@FezVrasta
Copy link
Member

FezVrasta commented May 7, 2020

I don't know why they use useState in the docs at all in the place of a ref lol. Complete nonsense.

Yeah, it's complete nonsense:

[...] useRef is the wrong thing to use when you need to be updated when they change. Instead you should use a "callback ref" (react's confusing name not mine).

[..]

references:
https://reactjs.org/docs/refs-and-the-dom.html#callback-refs
https://twitter.com/sebmarkbage/status/1091808948523581440

Source | #241 (comment)

@ghost
Copy link

ghost commented May 7, 2020

Relative to the popper instance nothing is changing, so a ref should be totally fine. Furthermore, I would imagine the ref prop expects a ref object with a current field so how can we be so sure state will work as expected?

Might be more useful to have a declarative API that follows something like blueprint's popper, have a Popper component which parses two children the first being the target and the second being the content instead and allow additional props.

@ywtstewart
Copy link

Yes, more docs please. Haven't gotten hooks to work.
https://codesandbox.io/s/peaceful-grothendieck-gw6zy?file=/src/App.js

@FezVrasta
Copy link
Member

@ywtstewart your example is working, I'm not sure what you expect it to do...

@ghost
Copy link

ghost commented May 10, 2020

https://codesandbox.io/s/twilight-bash-h6ruv?file=/src/App.js

Is there a way to edge align the popper and the target button? I know I can use "placement" but I want it to be smart enough to know when the target button is right aligned or left aligned and act accordingly if that makes sense.

@floating-ui floating-ui locked and limited conversation to collaborators May 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants