fix(form): [form] fix dynamic change size fail in prod mode (#1857)

This commit is contained in:
gimmyhehe 2024-08-07 17:51:56 +08:00 committed by GitHub
parent 0a693e7b56
commit 4dbc4d3dfc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 5 deletions

View File

@ -26,7 +26,7 @@ test('测试表单禁用', async ({ page }) => {
await expect(formItem.nth(5).locator('input').nth(1)).toBeDisabled()
await expect(formItem.nth(6).locator('input').first()).toBeDisabled()
await expect(formItem.nth(7).locator('input').first()).toBeDisabled()
await expect(formItem.nth(8).locator('input')).toBeDisabled()
await expect(formItem.nth(8).locator('input').first()).toBeDisabled()
await expect(formItem.nth(9).locator('input')).toBeDisabled()
await expect(formItem.nth(10).locator('input')).toBeDisabled()
await expect(formItem.nth(11).locator('textarea')).toBeDisabled()
@ -53,7 +53,7 @@ test('测试表单禁用', async ({ page }) => {
await expect(formItem.nth(5).locator('input').nth(1)).not.toBeDisabled()
await expect(formItem.nth(6).locator('input').first()).not.toBeDisabled()
await expect(formItem.nth(7).locator('input').first()).not.toBeDisabled()
await expect(formItem.nth(8).locator('input')).not.toBeDisabled()
await expect(formItem.nth(8).locator('input').first()).not.toBeDisabled()
await expect(formItem.nth(9).locator('input')).not.toBeDisabled()
await expect(formItem.nth(10).locator('input')).not.toBeDisabled()
await expect(formItem.nth(11).locator('textarea')).not.toBeDisabled()

View File

@ -129,8 +129,8 @@ export default defineComponent({
typeof this.appendToBody === 'boolean'
? this.appendToBody
: typeof formAppendToBody === 'boolean'
? formAppendToBody
: true
? formAppendToBody
: true
const validatePosition = this.validatePosition || state.formInstance?.validatePosition || 'top-end'
const popperOptions = {
@ -160,7 +160,11 @@ export default defineComponent({
let item = parseVnode(vnode)
item.props = item.props || {}
const { type } = item
// productionsize
item.dynamicProps = item.dynamicProps || []
if (!item.dynamicProps.includes('size')) {
item.dynamicProps.push('size')
}
Object.assign(item.props, {
size: state.formItemSize,
mini: state.formItemSize === 'mini' || Boolean(item.props.mini)