Skip to content

Commit b13c5c9

Browse files
fix(ui): exclude unnamed tab labels from filter and groupBy field options (#9965)
### What? Currently when showing available columns to filter on and group by it will show fields inside tabs prepended with the tab name and an angle bracket as separator. ### Why? This current label makes sense when the tab has a name and also acts like a group. But in my opinion it does not make sense when tab does not have a name and is only used for presentational purposes. This shows very well with the SEO plugin where the SEO fields are inside a group field, so when used as a tab as well the SEO is shown double. This makes the naming consistent with how we show columns in the list view where unnamed tab has its fields hoisted. ### How? Check for tab name and only include the tab label as prefix when the tab has a name ### Before - inconsistency between column name and filter name ![before pages](https://github.com/user-attachments/assets/9ffe2eb5-0a03-461b-8aa6-86ffcc258ad0) ![before tabs](https://github.com/user-attachments/assets/c556e4bc-b6ac-4082-a086-30f3a5b031cc) <img width="1343" height="609" alt="before groupby" src="https://github.com/user-attachments/assets/5f2a0f0a-4500-4a94-8dd7-bd78fb057caf" /> ### After - consistency between column name and filter name ![after pages](https://github.com/user-attachments/assets/d6d6d6a1-5d1c-45bd-8718-5950e3bb599e) ![after tabs](https://github.com/user-attachments/assets/39048002-6064-4209-ba17-389329e4f3c0) <img width="1328" height="613" alt="after groupby" src="https://github.com/user-attachments/assets/a6a6f2c3-290a-4688-b658-30364871806f" />
1 parent ac16116 commit b13c5c9

3 files changed

Lines changed: 23 additions & 26 deletions

File tree

packages/ui/src/utilities/reduceFieldsToOptions.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ export const reduceFieldsToOptions = ({
6666
if (typeof tab.label !== 'boolean') {
6767
const localizedTabLabel = getTranslation(tab.label, i18n)
6868

69-
const labelWithPrefix = labelPrefix
70-
? labelPrefix + ' > ' + localizedTabLabel
71-
: localizedTabLabel
69+
const labelWithPrefix = tabHasName(tab)
70+
? labelPrefix
71+
? labelPrefix + ' > ' + localizedTabLabel
72+
: localizedTabLabel
73+
: labelPrefix
7274

7375
// Make sure we handle nested tabs
7476
const tabPathPrefix =

test/access-control/e2e.spec.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,13 +1222,13 @@ describe('Access Control', () => {
12221222

12231223
// Wait for dropdown options to load by waiting for the visible field
12241224
const visibleOption = initialField.locator('.rs__option', {
1225-
hasText: 'Public Tab > Public Data',
1225+
hasText: 'Public Data',
12261226
})
12271227
await expect(visibleOption).toBeVisible()
12281228

12291229
// Should hide secretInPublicTab field
12301230
await expect(
1231-
initialField.locator('.rs__option', { hasText: 'Public Tab > Secret In Public Tab' }),
1231+
initialField.locator('.rs__option', { hasText: 'Secret In Public Tab' }),
12321232
).toBeHidden()
12331233
})
12341234

@@ -1392,14 +1392,12 @@ describe('Access Control', () => {
13921392

13931393
// Wait for dropdown options to load by waiting for the visible field
13941394
const visibleOption = field.locator('.rs__option', {
1395-
hasText: 'Public Tab > Public Data',
1395+
hasText: 'Public Data',
13961396
})
13971397
await expect(visibleOption).toBeVisible()
13981398

13991399
// Should hide secretInPublicTab field
1400-
await expect(
1401-
field.locator('.rs__option', { hasText: 'Public Tab > Secret In Public Tab' }),
1402-
).toBeHidden()
1400+
await expect(field.locator('.rs__option', { hasText: 'Secret In Public Tab' })).toBeHidden()
14031401
})
14041402

14051403
test('should hide field with read: false inside named tab in groupBy dropdown', async () => {

test/admin/e2e/list-view/e2e.spec.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ describe('List View', () => {
9191
testInfo.setTimeout(TEST_TIMEOUT_LONG)
9292

9393
process.env.SEED_IN_CONFIG_ONINIT = 'false' // Makes it so the payload config onInit seed is not run. Otherwise, the seed would be run unnecessarily twice for the initial test run - once for beforeEach and once for onInit
94-
;({ payload, serverURL } = await initPayloadE2ENoConfig<Config>({
95-
dirname,
96-
prebuild,
97-
}))
94+
; ({ payload, serverURL } = await initPayloadE2ENoConfig<Config>({
95+
dirname,
96+
prebuild,
97+
}))
9898

9999
geoUrl = new AdminUrlUtil(serverURL, geoCollectionSlug)
100100
arrayUrl = new AdminUrlUtil(serverURL, arrayCollectionSlug)
@@ -427,11 +427,11 @@ describe('List View', () => {
427427
await whereBuilder.locator('.where-builder__add-first-filter').click()
428428
const conditionField = whereBuilder.locator('.condition__field')
429429
await conditionField.click()
430-
await conditionField.locator('input.rs__input').fill('Tab 1 > Title')
430+
await conditionField.locator('input.rs__input').fill('Title')
431431

432432
await expect(
433433
conditionField.locator('.rs__menu-list').locator('div', {
434-
hasText: exactText('Tab 1 > Title'),
434+
hasText: exactText('Title'),
435435
}),
436436
).toBeVisible()
437437
})
@@ -618,8 +618,7 @@ describe('List View', () => {
618618
test('should accept where query from complex, valid URL where parameter using the near operator', async () => {
619619
// We have one point collection with the point [5,-5] and one with [7,-7]. This where query should kick out the [5,-5] point
620620
await page.goto(
621-
`${
622-
new AdminUrlUtil(serverURL, 'geo').list
621+
`${new AdminUrlUtil(serverURL, 'geo').list
623622
}?limit=10&page=1&where[or][0][and][0][point][near]=6,-7,200000`,
624623
)
625624

@@ -696,7 +695,7 @@ describe('List View', () => {
696695

697696
await addListFilter({
698697
page,
699-
fieldLabel: 'Tab 1 > Title',
698+
fieldLabel: 'Title',
700699
operatorLabel: 'equals',
701700
value: 'test',
702701
})
@@ -710,7 +709,7 @@ describe('List View', () => {
710709

711710
const { whereBuilder } = await addListFilter({
712711
page,
713-
fieldLabel: 'Tab 1 > Title',
712+
fieldLabel: 'Title',
714713
operatorLabel: 'equals',
715714
value: 'Test',
716715
})
@@ -721,7 +720,7 @@ describe('List View', () => {
721720

722721
await expect(
723722
secondLi.locator('.condition__field').locator('.rs__single-value'),
724-
).toContainText('Tab 1 > Title')
723+
).toContainText('Title')
725724

726725
await expect(secondLi.locator('.condition__operator >> input')).toHaveValue('')
727726
await expect(secondLi.locator('.condition__value >> input')).toHaveValue('')
@@ -732,7 +731,7 @@ describe('List View', () => {
732731

733732
const { whereBuilder } = await addListFilter({
734733
page,
735-
fieldLabel: 'Tab 1 > Title',
734+
fieldLabel: 'Title',
736735
operatorLabel: 'equals',
737736
})
738737

@@ -781,7 +780,7 @@ describe('List View', () => {
781780

782781
const { whereBuilder } = await addListFilter({
783782
page,
784-
fieldLabel: 'Tab 1 > Title',
783+
fieldLabel: 'Title',
785784
operatorLabel: 'equals',
786785
value: 'Test 1',
787786
})
@@ -797,11 +796,9 @@ describe('List View', () => {
797796
const secondValueField = secondLi.locator('.condition__value >> input')
798797
await secondConditionField.click()
799798

800-
await secondConditionField
801-
.locator('.rs__option', { hasText: exactText('Tab 1 > Title') })
802-
.click()
799+
await secondConditionField.locator('.rs__option', { hasText: exactText('Title') }).click()
803800

804-
await expect(secondConditionField.locator('.rs__single-value')).toContainText('Tab 1 > Title')
801+
await expect(secondConditionField.locator('.rs__single-value')).toContainText('Title')
805802
await secondOperatorField.click()
806803
await secondOperatorField.locator('.rs__option').locator('text=equals').click()
807804
await secondValueField.fill('Test 2')

0 commit comments

Comments
 (0)