diff --git a/CHANGELOG.en-US.md b/CHANGELOG.en-US.md
index 4ed80e170..ce94d8e30 100644
--- a/CHANGELOG.en-US.md
+++ b/CHANGELOG.en-US.md
@@ -1,6 +1,12 @@
# CHANGELOG
-## 2.12.1
+## 2.12.2 (2021-06-19)
+
+### Fixes
+
+- Fix `n-form-item` always show require mark.
+
+## 2.12.1 (2021-06-19)
### Feats
diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md
index 2e1a58482..e78120f36 100644
--- a/CHANGELOG.zh-CN.md
+++ b/CHANGELOG.zh-CN.md
@@ -1,6 +1,12 @@
# CHANGELOG
-## 2.12.1
+## 2.12.2 (2021-06-19)
+
+### Fixes
+
+- 修复 `n-form-item` 始终展示必需的星号
+
+## 2.12.1 (2021-06-19)
### Feats
diff --git a/design-notes/maintaining.md b/design-notes/maintaining.md
index 13d291a77..b86fcab60 100644
--- a/design-notes/maintaining.md
+++ b/design-notes/maintaining.md
@@ -34,8 +34,10 @@
- 新增属性
```
-- `n-xxx` add xxx prop.
-- `n-xxx` 新增 xxx 属性
+- `n-xxx` add `xxx` prop.
+- `n-xxx` 新增 `xxx` 属性
+
+注意 `xxx` 属性必须是 kebab-case,不能是 camelCase。
```
- 修复 Bug
diff --git a/package.json b/package.json
index a32a52c60..d0c28dae4 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "naive-ui",
- "version": "2.12.1",
+ "version": "2.12.2",
"description": "A Vue 3 Component Library. Fairly Complete, Customizable Themes, Uses TypeScript, Not Too Slow",
"main": "lib/index.js",
"module": "es/index.js",
diff --git a/src/form/src/Form.tsx b/src/form/src/Form.tsx
index 4ac5496be..b149cb628 100644
--- a/src/form/src/Form.tsx
+++ b/src/form/src/Form.tsx
@@ -41,7 +41,7 @@ const formProps = {
size: String as PropType<'small' | 'medium' | 'large'>,
showRequireMark: {
type: [Boolean, String] as PropType<'left' | 'right' | boolean>,
- default: 'right'
+ default: undefined
},
showFeedback: {
type: Boolean,
diff --git a/src/form/src/FormItem.tsx b/src/form/src/FormItem.tsx
index adc3f6869..b50fc61c6 100644
--- a/src/form/src/FormItem.tsx
+++ b/src/form/src/FormItem.tsx
@@ -401,6 +401,7 @@ export default defineComponent({
class={`${mergedClsPrefix}-form-item-label`}
style={this.mergedLabelStyle as any}
>
+ {/* undefined || 'right' || true || false */}
{this.mergedShowRequireMark !== 'left'
? renderSlot($slots, 'label', undefined, () => [this.label])
: null}
diff --git a/src/form/src/utils.ts b/src/form/src/utils.ts
index 9b1861984..6531456e6 100644
--- a/src/form/src/utils.ts
+++ b/src/form/src/utils.ts
@@ -57,10 +57,7 @@ export function formItemMisc (props: FormItemSetupProps) {
const mergedShowRequireMarkRef = computed(() => {
const { showRequireMark } = props
if (showRequireMark !== undefined) return showRequireMark
- if (NForm?.showRequireMark !== undefined) {
- return NForm.showRequireMark
- }
- return undefined
+ return NForm?.showRequireMark
})
const validationErroredRef = ref(false)
const mergedValidationStatusRef = computed(() => {
diff --git a/src/form/tests/Form.spec.ts b/src/form/tests/Form.spec.ts
deleted file mode 100644
index 7cba09817..000000000
--- a/src/form/tests/Form.spec.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { mount } from '@vue/test-utils'
-import { NForm } from '../index'
-
-describe('n-form', () => {
- it('should work with import on demand', () => {
- mount(NForm)
- })
-})
diff --git a/src/form/tests/Form.spec.tsx b/src/form/tests/Form.spec.tsx
new file mode 100644
index 000000000..3e8215b50
--- /dev/null
+++ b/src/form/tests/Form.spec.tsx
@@ -0,0 +1,92 @@
+import { mount } from '@vue/test-utils'
+import { h } from 'vue'
+import { NInput } from '../../input'
+import { NForm, NFormItem } from '../index'
+
+describe('n-form', () => {
+ it('should work with import on demand', () => {
+ mount(NForm)
+ })
+ describe('require mark', () => {
+ it("doesn't show by default", () => {
+ const wrapper = mount(() => (
+
+ {{
+ default: () => {
+ return (
+
+ {{
+ default: () =>
+ }}
+
+ )
+ }
+ }}
+
+ ))
+ expect(wrapper.find('.n-form-item-label__asterisk').exists()).toEqual(
+ false
+ )
+ })
+ it('shows when props.showRequireMark is set', () => {
+ const wrapper = mount(() => (
+
+ {{
+ default: () => {
+ return (
+
+ {{
+ default: () =>
+ }}
+
+ )
+ }
+ }}
+
+ ))
+ expect(wrapper.find('.n-form-item-label__asterisk').exists()).toEqual(
+ true
+ )
+ })
+ it('shows when required rule is set in form', () => {
+ const wrapper = mount(() => (
+
+ {{
+ default: () => {
+ return (
+
+ {{
+ default: () =>
+ }}
+
+ )
+ }
+ }}
+
+ ))
+ expect(wrapper.find('.n-form-item-label__asterisk').exists()).toEqual(
+ true
+ )
+ })
+ it('shows when required rule is set in form item', () => {
+ const wrapper = mount(() => (
+
+ {{
+ default: () => {
+ return (
+
+ {{
+ default: () =>
+ }}
+
+ )
+ }
+ }}
+
+ ))
+ expect(wrapper.find('.n-form-item-label__asterisk').exists()).toEqual(
+ true
+ )
+ })
+ })
+})
diff --git a/src/version.ts b/src/version.ts
index 3a3d83437..8fe4241e1 100644
--- a/src/version.ts
+++ b/src/version.ts
@@ -1 +1 @@
-export default '2.12.1'
+export default '2.12.2'