Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: n-input-group-label component is not affected by the size attribute of the n-form component #6507

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Fixes

- Fix `n-time-picker`'s `use-12-hours` type error warning, closes [#4308](https://github.com/tusen-ai/naive-ui/issues/4308)
- Fix `n-input-group-label` component is not affected by the `size` attribute of the `n-form` component, closes [#6504](https://github.com/tusen-ai/naive-ui/issues/6504)

### Features

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Fixes

- `n-time-picker` 的 `use-12-hours` 类型错误警告,关闭 [#4308](https://github.com/tusen-ai/naive-ui/issues/4308)
- 修复 `n-input-group-label` 不受表单组件 `n-form` 的 `size` 属性影响,关闭 [#6504](https://github.com/tusen-ai/naive-ui/issues/6504)

### Features

Expand Down
32 changes: 25 additions & 7 deletions src/input/src/InputGroupLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type PropType, computed, defineComponent, h } from 'vue'
import { useConfig, useTheme, useThemeClass } from '../../_mixins'
import { useConfig, useFormItem, useTheme, useThemeClass } from '../../_mixins'
import type { ThemeProps } from '../../_mixins'
import { createKey } from '../../_utils'
import type { ExtractPublicPropTypes } from '../../_utils'
Expand All @@ -10,10 +10,7 @@ import type { Size } from './interface'

export const inputGroupLabelProps = {
...(useTheme.props as ThemeProps<InputTheme>),
size: {
type: String as PropType<Size>,
default: 'medium'
},
size: String as PropType<Size>,
bordered: {
type: Boolean as PropType<boolean | undefined>,
default: undefined
Expand All @@ -30,6 +27,23 @@ export default defineComponent({
setup(props) {
const { mergedBorderedRef, mergedClsPrefixRef, inlineThemeDisabled }
= useConfig(props)

const formItem = useFormItem(props, {
mergedSize(NFormItem) {
const { size } = props
if (size !== undefined)
return size
if (NFormItem) {
const { mergedSize } = NFormItem
if (mergedSize.value !== undefined) {
return mergedSize.value
}
}
return 'medium'
}
})
const { mergedSizeRef } = formItem

const themeRef = useTheme(
'Input',
'-input-group-label',
Expand All @@ -39,7 +53,7 @@ export default defineComponent({
mergedClsPrefixRef
)
const cssVarsRef = computed(() => {
const { size } = props
const { value: size } = mergedSizeRef
const {
common: { cubicBezierEaseInOut },
self: {
Expand All @@ -66,14 +80,18 @@ export default defineComponent({
const themeClassHandle = inlineThemeDisabled
? useThemeClass(
'input-group-label',
computed(() => props.size[0]),
computed(() => {
const { value: size } = mergedSizeRef
return size[0]
}),
cssVarsRef,
props
)
: undefined
return {
mergedClsPrefix: mergedClsPrefixRef,
mergedBordered: mergedBorderedRef,
mergedSize: mergedSizeRef,
cssVars: inlineThemeDisabled ? undefined : cssVarsRef,
themeClass: themeClassHandle?.themeClass,
onRender: themeClassHandle?.onRender
Expand Down
Loading