Skip to content

Commit

Permalink
feat(next/antd/vue): add useResponsiveFormLayout fault tolerance and …
Browse files Browse the repository at this point in the history
…FormItem useOverflow update (#2707)
  • Loading branch information
ifblooms authored Dec 30, 2021
1 parent 88915bc commit 98a544a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion packages/antd/src/form-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ function useOverflow<
const [overflow, setOverflow] = useState(false)
const containerRef = useRef<Container>()
const contentRef = useRef<Content>()
const layout = useFormLayout()
const labelCol = JSON.stringify(layout.labelCol)

useEffect(() => {
if (containerRef.current && contentRef.current) {
Expand All @@ -101,7 +103,7 @@ function useOverflow<
if (overflow) setOverflow(false)
}
}
}, [])
}, [labelCol])

return {
overflow,
Expand Down
4 changes: 3 additions & 1 deletion packages/antd/src/form-layout/useResponsiveFormLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ export const useResponsiveFormLayout: IUseResponsiveFormLayout = (props) => {
const [layoutProps, setLayout] = useState<any>(props)

const updateUI = () => {
setLayout(calculateProps(ref.current, props))
if (ref.current) {
setLayout(calculateProps(ref.current, props))
}
}

useEffect(() => {
Expand Down
4 changes: 3 additions & 1 deletion packages/element/src/form-layout/useResponsiveFormLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export const useResponsiveFormLayout: IUseResponsiveFormLayout = (
const layoutProps = ref<IProps>(props)

const updateUI = () => {
layoutProps.value = calculateProps(root.value, props)
if (root.value) {
layoutProps.value = calculateProps(root.value, props)
}
}

onMounted(() => {
Expand Down
4 changes: 3 additions & 1 deletion packages/next/src/form-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ function useOverflow<
const [overflow, setOverflow] = useState(false)
const containerRef = useRef<Container>()
const contentRef = useRef<Content>()
const layout = useFormLayout()
const labelCol = JSON.stringify(layout.labelCol)

useEffect(() => {
if (containerRef.current && contentRef.current) {
Expand All @@ -101,7 +103,7 @@ function useOverflow<
if (overflow) setOverflow(false)
}
}
}, [])
}, [labelCol])

return {
overflow,
Expand Down
4 changes: 3 additions & 1 deletion packages/next/src/form-layout/useResponsiveFormLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ export const useResponsiveFormLayout: IUseResponsiveFormLayout = (props) => {
const [layoutProps, setLayout] = useState<IProps>(props)

const updateUI = () => {
setLayout(calculateProps(ref.current, props))
if (ref.current) {
setLayout(calculateProps(ref.current, props))
}
}

useEffect(() => {
Expand Down

0 comments on commit 98a544a

Please sign in to comment.