Merge pull request #1766 from jacobsfletch/fix/1765
fix: error clearing date field
This commit is contained in:
@@ -89,7 +89,7 @@ const DateTime: React.FC<Props> = (props) => {
|
||||
placeholder={getTranslation(placeholder, i18n)}
|
||||
readOnly={readOnly}
|
||||
onChange={(incomingDate) => {
|
||||
if (!readOnly) setValue(incomingDate.toISOString());
|
||||
if (!readOnly) setValue(incomingDate?.toISOString() || null);
|
||||
}}
|
||||
value={value as Date}
|
||||
/>
|
||||
|
||||
@@ -374,6 +374,18 @@ describe('fields', () => {
|
||||
url = new AdminUrlUtil(serverURL, 'date-fields');
|
||||
});
|
||||
|
||||
test('should clear date', async () => {
|
||||
await page.goto(url.create);
|
||||
const dateField = page.locator('#field-default input');
|
||||
await expect(dateField).toBeVisible();
|
||||
await dateField.fill('2021-08-01');
|
||||
await expect(dateField).toHaveValue('2021-08-01');
|
||||
const clearButton = page.locator('#field-default .date-time-picker__clear-button');
|
||||
await expect(clearButton).toBeVisible();
|
||||
await clearButton.click();
|
||||
await expect(dateField).toHaveValue('');
|
||||
});
|
||||
|
||||
test('should display formatted date in list view if displayFormat option added to date field', async () => {
|
||||
await page.goto(url.list);
|
||||
const formattedDateCell = page.locator('.row-1 .cell-timeOnly');
|
||||
|
||||
Reference in New Issue
Block a user