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

[Select] Add ability to position as popper #1853

Merged
merged 9 commits into from
Jan 16, 2023
Merged

Conversation

benoitgrelard
Copy link
Collaborator

Fixes #1247

@Andrii-Antoniuk
Copy link

Does this also contain a fix for non-modal mode?

Copy link

@timothympace timothympace left a comment

Choose a reason for hiding this comment

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

@benoitgrelard This looks great! These are the exact CSS vars I need to constrain the height of my dropdown. What more is remaining on this PR? I see it's still a draft. Is there any way I can help out? (tests needed? etc?)

@benoitgrelard
Copy link
Collaborator Author

@Andrii-Antoniuk, it might be possible in the new positioning mode now, but will be in another PR. We'll prioritise releasing this change for now.

@benoitgrelard benoitgrelard marked this pull request as ready for review January 9, 2023 10:35
Copy link
Collaborator

@andy-hook andy-hook left a comment

Choose a reason for hiding this comment

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

Looking really solid, added a few small bits a pieces but nothing major. I didn't review the positioning logic from the previous implementation as I assume nothing changed there?

packages/react/popper/src/Popper.tsx Outdated Show resolved Hide resolved
packages/react/popper/src/Popper.tsx Show resolved Hide resolved
*/
onPointerDownOutside?: DismissableLayerProps['onPointerDownOutside'];

position?: 'outside' | 'above';
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sold on above, it feels too similar to the other popper settings and possibly be confused with side="top".

Quick thought?
positioning: 'outside' | 'integrated'

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sold on integrated. I thought about this quite a lot, but it's quite hard to find a balance between:

  • something that describes it opens outside like a popper, but can't be called "dropdown", "bottom", "below", etc as we don't know which direction it will open (hence why I went with "outside")
  • something that describes it opens "on top" (felt too similar to "top") so went with "above"

Maybe "layered"? What were your thoughts for "integrated"?

Copy link

Choose a reason for hiding this comment

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

Maybe "over"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Haha cheers for chiming in @atomiks!
It's tough! "over" also could be confused with "above"/"top" although it does carry a bit more meaning.
What do you think @andy-hook?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was thinking integrated because the content is "integrated" with the trigger and has strong opinions on the position and layout.

I do like over the most though, it adds a bit more meaning (to my mental model at least)

I'd be happy to move forward with that.

Choose a reason for hiding this comment

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

Is dropdown too vague? <Select dropdown />

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe asDropdown? That might not be a bad shout as the way most people would ask for this specific feature was: "How do I make the Select position like the DropdownMenu one?"

Copy link
Collaborator

Choose a reason for hiding this comment

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

My problem with asXX is that we've established it as a convention for modifying the underlying node (asChild), we also have a DropdownMenu primitive which could be confusing? I think our naming should have relation to other positioning type props e.g. hideWhenDetached, avoidCollisions.

Choose a reason for hiding this comment

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

Yep, I agree with the asXX sentiment there. We could consider popper. It's inline with modal on Dialog. Component vs Behaviour kinda thing.

Oooooor... position="dropdown" | "overlay"? 😬

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@andy-hook have done a little bit more discussion on this and decided to go with:

position?: 'item-aligned' | 'popper';

with 'item-aligned' being the default still.

packages/react/select/src/Select.tsx Outdated Show resolved Hide resolved
packages/react/select/src/Select.tsx Show resolved Hide resolved
packages/react/select/src/Select.tsx Outdated Show resolved Hide resolved
packages/react/select/src/Select.tsx Outdated Show resolved Hide resolved
packages/react/select/src/Select.tsx Outdated Show resolved Hide resolved
packages/react/select/src/Select.tsx Outdated Show resolved Hide resolved
@benoitgrelard
Copy link
Collaborator Author

I didn't review the positioning logic from the previous implementation as I assume nothing changed there?

No it hasn't, if you look at each commit you should be able to see it's just moving stuff around.

@benoitgrelard
Copy link
Collaborator Author

@andy-hook I've just realised also that I made onPlaced a private prop for Select but haven't touched the other components that use Popper so these would have it as public.

Do you think it's worth adding to the public API? Or should I omit it from the other primitives too?

@andy-hook
Copy link
Collaborator

Do you think it's worth adding to the public API? Or should I omit it from the other primitives too?

We should omit it until needed

Copy link
Collaborator

@andy-hook andy-hook left a comment

Choose a reason for hiding this comment

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

💯

@benoitgrelard benoitgrelard merged commit ec1f671 into main Jan 16, 2023
@benoitgrelard benoitgrelard deleted the select-popper branch January 16, 2023 12:23
@Andrii-Antoniuk
Copy link

When do you have a release date? :) Thanks for your work! ❤️

@benoitgrelard
Copy link
Collaborator Author

It should be released tomorrow if all goes to plan!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Select] Allow positioning of options beneath trigger
6 participants