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

feat(DropdownMenu): Add responsive menu alignment #5307

Conversation

kyletsang
Copy link
Member

src/DropdownMenu.tsx Outdated Show resolved Hide resolved
src/DropdownMenu.tsx Show resolved Hide resolved
src/DropdownMenu.tsx Outdated Show resolved Hide resolved
src/DropdownMenu.tsx Outdated Show resolved Hide resolved
@kyletsang kyletsang requested a review from taion August 11, 2020 05:55
taion
taion previously approved these changes Aug 11, 2020
@taion taion dismissed their stale review August 11, 2020 15:20

misclick

DEVICE_SIZES.forEach((brkPoint) => {
const direction = align[brkPoint];
if (direction) {
alignRight = alignRight || direction === 'left';
Copy link
Member

Choose a reason for hiding this comment

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

question: i'm confused by this – we set alignRight to true if any direction is left? that seems a little odd to me

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry should've left a comment here. In order to responsively align left, the dropdown-menu-right class needs to be added in addition to dropdown-menu-**-left. I reused this bool to control toggling of that class.

https://getbootstrap.com/docs/4.5/components/dropdowns/#responsive-alignment

src/DropdownMenu.tsx Outdated Show resolved Hide resolved
src/DropdownMenu.tsx Show resolved Hide resolved
@taion taion closed this Aug 12, 2020
@taion taion reopened this Aug 12, 2020
@taion
Copy link
Member

taion commented Aug 12, 2020

wait a sec... per #5304 (comment) – should we then have some sort of check that only a single key is specified in the object?

i.e. it wouldn't make sense to specify more than one align class, i think?

Copy link
Member

@taion taion left a comment

Choose a reason for hiding this comment

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

sorry misclicked

src/DropdownMenu.tsx Show resolved Hide resolved
src/DropdownMenu.tsx Show resolved Hide resolved
@taion
Copy link
Member

taion commented Aug 12, 2020

e.g. if i'm reading the bootstrap docs correctly, the type should be more like

AlignDirection
| { sm: AlignDirection }
| { md: AlignDirection }
| { lg: AlignDirection }
| { xl: AlignDirection }

@taion
Copy link
Member

taion commented Aug 12, 2020

cc @jquense – was that what you meant by "can't specify bad combos"?

@kyletsang
Copy link
Member Author

Oops, was thinking multiple aligns were allowed. I'll fix that up

@taion
Copy link
Member

taion commented Aug 12, 2020

well, are they? the upstream docs at least suggest that it makes little sense

@kyletsang
Copy link
Member Author

Adding the combination of classes do allow you to flip flop on diff screen sizes. But yeah prob not a practical thing.

@kyletsang
Copy link
Member Author

Fixed code to only handle 1 breakpoint in the align object and warn if object doesn't contain exactly 1 breakpoint.

@kyletsang kyletsang requested a review from taion August 13, 2020 00:06
Copy link
Member

@taion taion left a comment

Choose a reason for hiding this comment

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

@jquense can you just confirm that this is the API you were thinking of?

@jquense
Copy link
Member

jquense commented Aug 17, 2020

I think you should be allows to specify combos together no? At least thats supported for other cases of responsive variants.

@taion
Copy link
Member

taion commented Aug 17, 2020

@jquense upstream doesn't show it https://getbootstrap.com/docs/4.5/components/dropdowns/#responsive-alignment

would a user really want to flip back and forth on direction? the way the "left" thing is set up doesn't quite enable that...

e.g. if you want it go to "left" at ">= md", we'd need to also add the "align right" as the default... otherwise we'd need a slightly different/clunkier API here? e.g. we'd have to force users to specify alignEnd as the "default" behavior?

@kyletsang kyletsang requested a review from jquense August 28, 2020 17:07
@kyletsang kyletsang merged commit b5ec39e into react-bootstrap:master Aug 31, 2020
@kyletsang kyletsang deleted the feat/dropdown-menu-responsive-alignment branch August 31, 2020 04:18
@kyletsang kyletsang linked an issue Aug 31, 2020 that may be closed by this pull request
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.

Add DropdownMenu responsive alignment
3 participants