diff --git a/packages/vant-cli/src/cli.ts b/packages/vant-cli/src/cli.ts index bdefe31bf..d2d866de0 100644 --- a/packages/vant-cli/src/cli.ts +++ b/packages/vant-cli/src/cli.ts @@ -45,6 +45,10 @@ program '--runInBand', 'Run all tests serially in the current process, rather than creating a worker pool of child processes that run tests' ) + .option( + '--updateSnapshot', + 'Re-record every snapshot that fails during this test run' + ) .option('--debug', 'Print debugging info about your Jest config') .action(async (options) => { const { test } = await import('./commands/jest.js'); diff --git a/packages/vant-cli/src/commands/jest.ts b/packages/vant-cli/src/commands/jest.ts index 284a95c44..1ba81287b 100644 --- a/packages/vant-cli/src/commands/jest.ts +++ b/packages/vant-cli/src/commands/jest.ts @@ -24,6 +24,7 @@ export function test(command: Config.Argv) { clearCache: command.clearCache, changedSince: command.changedSince, logHeapUsage: command.logHeapUsage, + updateSnapshot: command.updateSnapshot, // make jest tests faster // see: https://ivantanev.com/make-jest-faster/ maxWorkers: '50%', diff --git a/packages/vant/package.json b/packages/vant/package.json index 6e0c3f264..5292dbdf4 100644 --- a/packages/vant/package.json +++ b/packages/vant/package.json @@ -20,6 +20,7 @@ "build:site": "vant-cli build-site", "release": "cp ../../README.md ./ && vant-cli release && rm ./README.md", "release:site": "pnpm build:site && npx gh-pages -d site-dist --add", + "test:update": "vant-cli test --updateSnapshot", "test:watch": "vant-cli test --watch", "test:coverage": "open test/coverage/index.html" }, diff --git a/packages/vant/src/field/Field.tsx b/packages/vant/src/field/Field.tsx index d6c1341b0..e1b7f977a 100644 --- a/packages/vant/src/field/Field.tsx +++ b/packages/vant/src/field/Field.tsx @@ -434,7 +434,8 @@ export default defineComponent({ const labelStyle = computed(() => { const labelWidth = getProp('labelWidth'); - if (labelWidth) { + const labelAlign = getProp('labelAlign'); + if (labelWidth && labelAlign !== 'top') { return { width: addUnit(labelWidth) }; } }); @@ -571,6 +572,8 @@ export default defineComponent({ }; const renderLabel = () => { + const labelWidth = getProp('labelWidth'); + const labelAlign = getProp('labelAlign'); const colon = getProp('colon') ? ':' : ''; if (slots.label) { @@ -578,7 +581,15 @@ export default defineComponent({ } if (props.label) { return ( -