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

[TypeScript] Fix <WrapperField source> prop should not be required #9983

Merged
merged 1 commit into from
Jul 9, 2024
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
22 changes: 22 additions & 0 deletions packages/ra-ui-materialui/src/field/WrapperField.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { render } from '@testing-library/react';
import expect from 'expect';
import * as React from 'react';

import { UrlField } from './UrlField';
import { WrapperField } from './WrapperField';

const url = 'https://en.wikipedia.org/wiki/HAL_9000';

describe('<WrapperField />', () => {
it('should render its children', () => {
const record = { id: 123, website: url };
const { getByText } = render(
<WrapperField label="wrapper">
<UrlField record={record} source="website" />
</WrapperField>
);
const link = getByText(url) as HTMLAnchorElement;
expect(link.tagName).toEqual('A');
expect(link.href).toEqual(url);
});
});
3 changes: 2 additions & 1 deletion packages/ra-ui-materialui/src/field/WrapperField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ WrapperField.displayName = 'WrapperField';

export interface WrapperFieldProps<
RecordType extends Record<string, any> = Record<string, any>,
> extends FieldProps<RecordType> {
> extends Omit<FieldProps<RecordType>, 'source'> {
source?: FieldProps<RecordType>['source'];
children: ReactNode;
}
Loading