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

SelectField doesn't work inside Dialog #8

Open
vsviridov opened this issue Nov 20, 2016 · 3 comments · May be fixed by #18
Open

SelectField doesn't work inside Dialog #8

vsviridov opened this issue Nov 20, 2016 · 3 comments · May be fixed by #18

Comments

@vsviridov
Copy link

vsviridov commented Nov 20, 2016

The drop downs are rendered underneath the dialog and are invisible.

import { Dialog, DialogContent } from 'react-mdl';
import { SelectField, Option } from 'react-mdl-extra';

export default (props) => (
  <Dialog open={props.open}>
    <DialogContent>
      <SelectField>
        <Option value={1}>One</Option>
      </SelectField>
    </DialogContent>
  </Dialog>
);
@shanehughes3
Copy link
Contributor

This seems to be caused by two things:

  • the <Dialog> component from react-mdl uses the <dialog> html tag, which places its content in the top layer of the page, above all other content.
  • the <SelectField> component from this package (or, more accurately, the <Dropdown> component rendered by <SelectField>) renders the <OptionList> within a portal, making it a child of <body> and not the dialog.

There's not really an easy way around this, though I think it is something worth addressing since it's not exactly a rare case. I see two options:

  • sending the <OptionList> to the top layer itself by calling showModal() on it, where it will be stacked atop the dialog. This would require some extra handlers and pseudoclasses to get it to act naturally within the dialog. I'm not a fan of this method because <dialog> (the HTML tag, not the react-mdl element) is only supported natively in chrome and opera, so polyfill would have to be included just to use <SelectField>. Plus this just seems like a hack.
  • ditching the portal and making the <OptionList> a child of the dialog. I don't know the implications of this (I imagine there might be some overflow issues), but it seems like it might be the cleaner solution.

What do you think @HriBB ?

@HriBB
Copy link
Owner

HriBB commented Jan 24, 2017

@shanehughes3 thanks for the info! Yeah there are some problems with react-portal. This is one of them. Another one is controlling portal isOpened prop manually which is needed for keyboard handling.
One of the early versions used its own implementation of portal, but that brings a lot of complexity into the project. And bugs.

Maybe we can add inline prop, which renders dropdown inside component?

@HriBB
Copy link
Owner

HriBB commented Jan 24, 2017

In the future I will probably switch to https://material-components-web.appspot.com/ or something, because MDL v1 is not very react friendly.

@jguffey jguffey linked a pull request Mar 28, 2017 that will close this issue
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 a pull request may close this issue.

3 participants