Records: default to newest first on the source's date field
The page loaded unsorted, so the most recent rows were rarely on screen. On source change it now looks up the source's first date-typed field and sorts descending on it, falling back to unsorted when a source has no date field. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
ba4e382487
commit
426f975d9c
@ -119,7 +119,14 @@ export default function Records({ source }) {
|
||||
setPanelOpen(false)
|
||||
setOverrideCols([])
|
||||
setExtraCols([])
|
||||
load(0, null, 'asc', [])
|
||||
// Default to newest first on the source's first date field, if it has one
|
||||
api.getSource(source)
|
||||
.then(src => (src?.config?.fields || []).find(f => f.type === 'date')?.name || null)
|
||||
.catch(() => null)
|
||||
.then(dateCol => {
|
||||
if (dateCol) setSort({ col: dateCol, dir: 'desc' })
|
||||
load(0, dateCol, 'desc', [])
|
||||
})
|
||||
api.getOverrideKeys(source).then(setOverrideCols).catch(() => {})
|
||||
api.getGlobalValues().then(setGlobalValues).catch(() => {})
|
||||
setSelected(new Set())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user