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

[Portal] Global option to disable the portal #11086

Merged

Conversation

oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Apr 20, 2018

Hack waiting for enzymejs/enzyme#252 to be solved.
When __MUI_PORTAL_DISABLE__ is set to true, the portal will behave as a pass-through component.

Closes #11074

@oliviertassinari oliviertassinari merged commit 6054e95 into mui:v1-beta Apr 21, 2018
@oliviertassinari oliviertassinari deleted the portal-disable-global branch April 21, 2018 00:09
@yoanisgil
Copy link

@oliviertassinari is this already usable? I mean is this available on npm? I want to give it a try today and see how it goes.

@oliviertassinari
Copy link
Member Author

@yoanisgil Yes

@oliviertassinari
Copy link
Member Author

Let me know how that goes.

@yoanisgil
Copy link

@oliviertassinari so I'm doing a test like this:

describe('Select Component tests', () => {
    beforeEach(() => {
        global.__MUI_PORTAL_DISABLE__ = true;
    });

    afterEach(() => {
        global.__MUI_PORTAL_DISABLE__ = false;
    });

    test('it should render', () => {
        let component = mount(<Select value={1}>
            <MenuItem value={1}>
                <em>1</em>
            </MenuItem>
            <MenuItem value={2}>
                <em>2</em>
            </MenuItem>

        </Select>);

        expect(component.find(MenuItem).length).toBe(2);
    });

});

which fails with:

  ● Select Component tests › it should render

    expect(received).toBe(expected)

    Expected value to be (using ===):
      2
    Received:
      0

I'm using "material-ui": "^1.0.0-beta.43". I'm doing something wrong ?

@oliviertassinari
Copy link
Member Author

@yoanisgil This is expected. The Select component is using the Modal. The Modal only renders its children when open.

@oliviertassinari
Copy link
Member Author

I'm reverting this pull-request. My bad.

@yoanisgil
Copy link

I see. Yeah that should do for our case. Thanks for all the support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Portal The React component. test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants