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

Fix prop-types validation for TabbedFormView's toolbar prop #8436

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions packages/ra-ui-materialui/src/form/TabbedForm.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,29 @@ describe('<TabbedForm />', () => {
)
).toEqual(true);
});

it('should not warn for `toolbar` prop of type `false`', () => {
const history = createMemoryHistory({ initialEntries: ['/'] });

const consoleSpy = jest
.spyOn(console, 'error')
.mockImplementation(() => {});

render(
<AdminContext dataProvider={testDataProvider()} history={history}>
<ResourceContextProvider value="posts">
<TabbedForm toolbar={false}>
<FormTab label="tab1"></FormTab>
</TabbedForm>
</ResourceContextProvider>
</AdminContext>
);

expect(consoleSpy).not.toBeCalledWith(
'Warning: Failed %s type: %s%s',
'prop',
expect.stringContaining('Invalid prop `toolbar` of type `boolean`'),
expect.stringContaining(`at ${TabbedForm.name}`)
);
});
});
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/form/TabbedFormView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ TabbedFormView.propTypes = {
// @ts-ignore
resource: PropTypes.string,
tabs: PropTypes.element,
toolbar: PropTypes.element,
toolbar: PropTypes.oneOfType([PropTypes.element, PropTypes.oneOf([false])]),
validate: PropTypes.func,
value: PropTypes.number,
};
Expand Down