Skip to content

Commit

Permalink
fix(antd/next): fix FormItem useOverflow bug (#2830)
Browse files Browse the repository at this point in the history
  • Loading branch information
ifblooms committed Feb 16, 2022
1 parent 55d28ed commit 5e88de2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 5 additions & 3 deletions packages/antd/src/form-item/index.tsx
Expand Up @@ -123,7 +123,7 @@ export const BaseItem: React.FC<IFormItemProps> = ({ children, ...props }) => {
const formLayout = useFormItemLayout(props)
const { containerRef, contentRef, overflow } = useOverflow<
HTMLDivElement,
HTMLLabelElement
HTMLSpanElement
>()
const {
label,
Expand Down Expand Up @@ -218,8 +218,10 @@ export const BaseItem: React.FC<IFormItemProps> = ({ children, ...props }) => {
const renderLabelText = () => {
const labelChildren = (
<div className={`${prefixCls}-label-content`} ref={containerRef}>
{asterisk && <span className={`${prefixCls}-asterisk`}>{'*'}</span>}
<label ref={contentRef}>{label}</label>
<span ref={contentRef}>
{asterisk && <span className={`${prefixCls}-asterisk`}>{'*'}</span>}
<label>{label}</label>
</span>
</div>
)

Expand Down
12 changes: 7 additions & 5 deletions packages/next/src/form-item/index.tsx
Expand Up @@ -124,7 +124,7 @@ export const BaseItem: React.FC<IFormItemProps> = (props) => {
const formLayout = useFormItemLayout(others)
const { containerRef, contentRef, overflow } = useOverflow<
HTMLDivElement,
HTMLLabelElement
HTMLSpanElement
>()
const {
label,
Expand Down Expand Up @@ -216,10 +216,12 @@ export const BaseItem: React.FC<IFormItemProps> = (props) => {
const renderLabelText = () => {
const labelChildren = (
<div className={cls(`${prefixCls}-label-content`)} ref={containerRef}>
{asterisk && (
<span className={cls(`${prefixCls}-asterisk`)}>{'*'}</span>
)}
<label ref={contentRef}>{label}</label>
<span ref={contentRef}>
{asterisk && (
<span className={cls(`${prefixCls}-asterisk`)}>{'*'}</span>
)}
<label>{label}</label>
</span>
</div>
)

Expand Down

0 comments on commit 5e88de2

Please sign in to comment.