fix: Label text was obscured in create agent page
This commit is contained in:
parent
8739c49634
commit
827959e580
@ -14,6 +14,7 @@ import { Button, Form, FormInstance, Input, Modal, Popover, Select, SelectProps
|
|||||||
import TextArea from 'antd/es/input/TextArea'
|
import TextArea from 'antd/es/input/TextArea'
|
||||||
import { useRef, useState } from 'react'
|
import { useRef, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import stringWidth from 'string-width'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
resolve: (data: Agent | null) => void
|
resolve: (data: Agent | null) => void
|
||||||
@ -104,6 +105,11 @@ const PopupContainer: React.FC<Props> = ({ resolve }) => {
|
|||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compute label width based on the longest label
|
||||||
|
const labelWidth = [t('agents.add.name'), t('agents.add.prompt'), t('agents.add.knowledge_base')]
|
||||||
|
.map((labelText) => stringWidth(labelText) * 8)
|
||||||
|
.reduce((maxWidth, currentWidth) => Math.max(maxWidth, currentWidth), 80)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={t('agents.add.title')}
|
title={t('agents.add.title')}
|
||||||
@ -117,7 +123,7 @@ const PopupContainer: React.FC<Props> = ({ resolve }) => {
|
|||||||
<Form
|
<Form
|
||||||
ref={formRef}
|
ref={formRef}
|
||||||
form={form}
|
form={form}
|
||||||
labelCol={{ flex: '80px' }}
|
labelCol={{ flex: `${labelWidth}px` }}
|
||||||
labelAlign="left"
|
labelAlign="left"
|
||||||
colon={false}
|
colon={false}
|
||||||
style={{ marginTop: 25 }}
|
style={{ marginTop: 25 }}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user