Skip to content

Commit efe17ff

Browse files
committed
fix(row): set max-width for row
1 parent 12fb691 commit efe17ff

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

packages/ui/src/forms/RenderFields/RenderField.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,19 @@ export const RenderField: React.FC<Props> = ({
8585
/>
8686
)
8787
} else {
88+
if (fieldComponentProps.field.type === 'row') {
89+
for (const field of fieldComponentProps.field.fields) {
90+
if (field.admin?.width) {
91+
field.admin.style = {
92+
...field.admin.style,
93+
maxWidth: field.admin.width,
94+
}
95+
96+
field.admin.width = undefined
97+
}
98+
}
99+
}
100+
88101
RenderedField = (
89102
<RenderComponent
90103
Component={fieldComponents?.[fieldComponentProps?.field?.type]}

test/fields/e2e.spec.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Page } from '@playwright/test'
1+
import type { Locator, Page } from '@playwright/test'
22

33
import { expect, test } from '@playwright/test'
44
import path from 'path'
@@ -374,9 +374,23 @@ describe('fields', () => {
374374
test('should render row fields inline and with explicit widths', async () => {
375375
await page.goto(url.create)
376376
const fieldA = page.locator('input#field-field_with_width_a')
377-
await expect(fieldA).toBeVisible()
378377
const fieldB = page.locator('input#field-field_with_width_b')
378+
379+
const fieldAGrandprent = fieldA.locator('..').locator('..')
380+
const fieldBGrandprent = fieldB.locator('..').locator('..')
381+
382+
await expect(fieldA).toBeVisible()
379383
await expect(fieldB).toBeVisible()
384+
385+
const hasCorrectCSS = async (el: Locator) => {
386+
return await el.evaluate((el) => {
387+
return el.style.width === '' && el.style.maxWidth === '50%'
388+
})
389+
}
390+
391+
expect(hasCorrectCSS(fieldAGrandprent)).toBeTruthy()
392+
expect(hasCorrectCSS(fieldBGrandprent)).toBeTruthy()
393+
380394
const fieldABox = await fieldA.boundingBox()
381395
const fieldBBox = await fieldB.boundingBox()
382396

0 commit comments

Comments
 (0)