fix(ui): date format of useAsTitle lost after changing value (#12928)
When a collection's `admin.useAsTitle` property points to a date field, the date format is lost after making a change to the field's value. Before: https://github.com/user-attachments/assets/10e61517-3245-4645-be4c-33017bfc860c After: https://github.com/user-attachments/assets/d3d62d2e-364e-48a2-91c1-2ce4b0962fe5 --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1210632330039313
This commit is contained in:
@@ -30,14 +30,9 @@ export const SetDocumentTitle: React.FC<{
|
||||
|
||||
const title = formatDocTitle({
|
||||
collectionConfig,
|
||||
data: { id: '' },
|
||||
data: { id: '', [useAsTitle]: field?.value || '' },
|
||||
dateFormat: dateFormatFromConfig,
|
||||
fallback:
|
||||
typeof field === 'string'
|
||||
? field
|
||||
: typeof field === 'number'
|
||||
? String(field)
|
||||
: (field?.value as string) || fallback,
|
||||
fallback,
|
||||
globalConfig,
|
||||
i18n,
|
||||
})
|
||||
|
||||
@@ -85,6 +85,19 @@ describe('Date', () => {
|
||||
await expect(page.locator('.doc-header__title.render-title')).toContainText('August')
|
||||
})
|
||||
|
||||
test('should retain date format in useAsTitle after modifying value', async () => {
|
||||
await page.goto(url.list)
|
||||
await page.locator('.row-1 .cell-default a').click()
|
||||
await expect(page.locator('.doc-header__title.render-title')).toContainText('August')
|
||||
|
||||
const dateField = page.locator('#field-default input')
|
||||
await expect(dateField).toBeVisible()
|
||||
await dateField.fill('02/07/2023')
|
||||
|
||||
await expect(dateField).toHaveValue('02/07/2023')
|
||||
await expect(page.locator('.doc-header__title.render-title')).toContainText('February')
|
||||
})
|
||||
|
||||
test('should clear date', async () => {
|
||||
await page.goto(url.create)
|
||||
const dateField = page.locator('#field-default input')
|
||||
|
||||
Reference in New Issue
Block a user