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

Transformation is not set correctly for dropdown menu when direction is up #62

Closed
pbugnion opened this issue Nov 17, 2018 · 4 comments
Closed

Comments

@pbugnion
Copy link
Contributor

pbugnion commented Nov 17, 2018

When creating a dropdown menu with direction == 'up', items do not show correctly. In particular, the style bottom is not set to auto and the transformation that is supposed to push the items above the dropdown is wrong.

screen shot 2018-11-17 at 14 53 55

@pbugnion
Copy link
Contributor Author

pbugnion commented Nov 18, 2018

Cause

tl;dr this is caused by dash using react 15, not 16.

Long version:

Setting direction = "up" as a prop works in Demo.js.

By looking at the reactstrap source code, reactstrap injects a prop called x-placement in RSDropdownMenu that changes depending on the dropdown direction.

Bootstrap then uses a selector based on x-placement to move the popup to the correct place.

The x-placement attribute is not a standard DOM attribute. It's just a bootstrap thing. In HTML, I believe you can inject arbitrary attributes on divs, but the expectation is that you use data attributes. Your custom attributes should start with data-. Bootstrap ignores this convention, presumably because it pre-dates it.

Up to React 15, any extra attributes passed to <div /> (or any other JSX DOM elements) just gets silently stripped out. In React 16, they get passed through. See here for changelog.

Thus, in Demo.js which uses React 16, the x-placement attribute makes its way into the DOM, where it is picked up by the bootstrap CSS.

screenshot 2018-11-18 at 10 57 14

When we use dash-renderer, the x-placement attribute gets stripped out. Because Dash silences React warnings, we don't see a console warning like Warning: Unknown prop x-placement on <div> tag (see this issue on Reactstrap for someone with similar problems), making it even harder to diagnose. The x-placement attribute is just missing from the div.

screenshot 2018-11-18 at 11 00 24


Moving forwards

I suggest finding out when dash-renderer is planning to move to React 16 and waiting till then. In the meantime, we can just disable direction = "up" in the prop types. @tcbegley If you're happy with that I can submit a quick PR.

@pbugnion
Copy link
Contributor Author

Dash-renderer has a PR for migrating to React 16:

plotly/dash-renderer#97

@tcbegley
Copy link
Collaborator

That’s some top investigative work, thanks @pbugnion! I think disabling the “up” option for now is the best thing, let’s log this as something to return to when dash renderer moves to react 16 along with support for modals.

@pbugnion
Copy link
Contributor Author

Closing this in favour of issue #65, which is more up-to-date. Thank you!

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

No branches or pull requests

2 participants