You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to set an optional Tab component as the first Tab inside a TabbedShowLayout component. Note: I solve it by setting a custom path to every Tab and making my own ShowButton.
Test to reproduce the problem in ra-ui-materialui package:
The test fails and you get a console error. console.error ../../node_modules/@material-ui/core/Tabs/Tabs.js:221 Material-UI: The value provided to the Tabs component is invalid. None of the Tabs' children match with /. You can provide one of the following values: //1, //2.
If you remove the {null} line, the test pass without errors.
import*asReactfrom'react';importexpectfrom'expect';import{cleanup,render}from'@testing-library/react';importTabbedShowLayoutfrom'./TabbedShowLayout';importTabfrom'./Tab';importTextFieldfrom'../field/TextField';import{createMemoryHistory}from'history';import{Router}from'react-router-dom';describe('<TabbedShowLayout />',()=>{afterEach(cleanup);constrenderWithRouter=children=>{consthistory=createMemoryHistory();return{
history,
...render(<Routerhistory={history}>{children}</Router>),};};it('should display the first valid Tab component and its content',()=>{const{ queryByText, history }=renderWithRouter(<TabbedShowLayoutbasePath="/"record={{id: 123}}resource="foo">{null}<Tablabel="Tab1"><TextFieldlabel="Field On Tab1"source="field1"/></Tab><Tablabel="Tab2"><TextFieldlabel="Field On Tab2"source="field2"/></Tab></TabbedShowLayout>);expect(queryByText('Tab1')).not.toBeNull();expect(queryByText('Field On Tab1')).not.toBeNull();});});
The text was updated successfully, but these errors were encountered:
WiXSL
changed the title
TabbedShowLayout component resolves path incorreclly when first tab is null
TabbedShowLayout component resolves path incorreclly if first tab is null
Sep 23, 2020
Seems to work.
Even trying setting <Tabs value={2}> (which doesn't exist) make the test pass.
import*asReactfrom'react';importexpectfrom'expect';import{render,cleanup}from'@testing-library/react';importTabsfrom'@material-ui/core/Tabs';importTabfrom'@material-ui/core/Tab';describe('<MuiTab />',()=>{afterEach(cleanup);it('should display the first valid Tab component',()=>{const{queryAllByText}=render(<Tabsvalue={0}>{null}<Tablabel="Tab1"/><Tablabel="Tab2"/></Tabs>);expect(queryAllByText('Tab1')).toHaveLength(1);});});
Trying to set an optional
Tab
component as the first Tab inside aTabbedShowLayout
component.Note: I solve it by setting a custom path to every Tab and making my own ShowButton.
Test to reproduce the problem in
ra-ui-materialui
package:The test fails and you get a console error.
console.error ../../node_modules/@material-ui/core/Tabs/Tabs.js:221 Material-UI: The value provided to the Tabs component is invalid. None of the Tabs' children match with
/. You can provide one of the following values: //1, //2.
If you remove the
{null}
line, the test pass without errors.The text was updated successfully, but these errors were encountered: