Skip to content

Commit 0e874c3

Browse files
committed
Fix prop-types validation for TabbedFormView's toolbar prop
1 parent f546099 commit 0e874c3

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

packages/ra-ui-materialui/src/form/TabbedForm.spec.tsx

+25
Original file line numberDiff line numberDiff line change
@@ -256,4 +256,29 @@ describe('<TabbedForm />', () => {
256256
)
257257
).toEqual(true);
258258
});
259+
260+
it('should not warn for `toolbar` prop of type `false`', () => {
261+
const history = createMemoryHistory({ initialEntries: ['/'] });
262+
263+
const consoleSpy = jest
264+
.spyOn(console, 'error')
265+
.mockImplementation(() => {});
266+
267+
render(
268+
<AdminContext dataProvider={testDataProvider()} history={history}>
269+
<ResourceContextProvider value="posts">
270+
<TabbedForm toolbar={false}>
271+
<FormTab label="tab1"></FormTab>
272+
</TabbedForm>
273+
</ResourceContextProvider>
274+
</AdminContext>
275+
);
276+
277+
expect(consoleSpy).not.toBeCalledWith(
278+
'Warning: Failed %s type: %s%s',
279+
'prop',
280+
expect.stringContaining('Invalid prop `toolbar` of type `boolean`'),
281+
expect.stringContaining(`at ${TabbedForm.name}`)
282+
);
283+
});
259284
});

packages/ra-ui-materialui/src/form/TabbedFormView.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ TabbedFormView.propTypes = {
112112
resource: PropTypes.string,
113113
tabs: PropTypes.element,
114114
toolbar: PropTypes.element,
115+
// toolbar: PropTypes.oneOfType([PropTypes.element, PropTypes.oneOf([false])]),
115116
validate: PropTypes.func,
116117
value: PropTypes.number,
117118
};

0 commit comments

Comments
 (0)