Skip to content
This repository was archived by the owner on Jul 19, 2019. It is now read-only.

Use 'absolute' positioning for menu instead of 'fixed'#70

Open
cdevienne wants to merge 1 commit intoreactjs:masterfrom
unlish:menu-position-absolute
Open

Use 'absolute' positioning for menu instead of 'fixed'#70
cdevienne wants to merge 1 commit intoreactjs:masterfrom
unlish:menu-position-absolute

Conversation

@cdevienne
Copy link
Copy Markdown

The 'fixed' approach has a major downside:

The 'fixed' referential may not be the document when a parent node has CSS transforms.
But getBoundedClientRect() remains relative to the document no matter what.
Calculating a fixed position from it is difficult.

Using 'absolute' positioning makes things a lot easier. It is how bootstrap
dropdown menu works for example.

The 'fixed' referential may not be the document when a parent node has CSS transforms.
But getBoundedClientRect() remains relative to the viewport no matter what.
Calculating a fixed position from it is difficult.

Using 'absolute' positioning makes things a lot easier. It is how bootstrap
dropdown menu works for example.
@mihaibogdan10
Copy link
Copy Markdown

Also, on pages that have enough content to have a scroll, position: fixed fails horribly.

@mihaibogdan10
Copy link
Copy Markdown

@cdevienne There's no need for that maxWidth hack now, having position relative on the parent makes width: 100% work just fine 😄

@CMTegner
Copy link
Copy Markdown
Collaborator

Just a heads-up (in case you're waiting for this PR to land): You can fully customize the dropdown menu by using props.menuStyle and props.renderMenu.

We'll probably be removing most of the default menu styles for 2.0, possibly only keeping the absolute coordinates which are passed to props.renderMenu (although you could calculate this yourself if we added support for rendering custom components instead of just fragments for the menu).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants