chenyong0923 opened a new issue, #1167: URL: https://github.com/apache/incubator-answer/issues/1167
 <img width="357" alt="image" src="https://github.com/user-attachments/assets/be64f8de-ca6f-4ecc-b68a-ee92d08f634d"> `typescript import React, { useMemo, useRef } from 'react'; import { Form, InputGroup } from 'react-bootstrap'; import type { FC } from 'react'; import { useTranslation } from 'react-i18next'; interface CustomFileInputProps { value: string; onChange: React.ChangeEventHandler<HTMLInputElement>; isValid?: boolean; isInvalid?: boolean; } const CustomFileInput: FC<CustomFileInputProps> = ({ onChange, value, ...rest }) => { const { t } = useTranslation('translation', { keyPrefix: 'editor' }); const fileName = useMemo(() => { return value ?? t('file_upload.text'); }, [value]); const fileRef = useRef<HTMLInputElement>(null); return ( <Form.Group> <Form.Control type="file" id="custom-file" onChange={onChange} style={{ zIndex: -1, position: 'absolute' }} // 隐藏默认控件 ref={fileRef} {...rest} /> <InputGroup className="mb-3"> <InputGroup.Text id="basic-addon1"> {t('file_upload.text')} </InputGroup.Text> <Form.Control type="text" readOnly value={fileName} aria-label={t('file_upload.text')} placeholder={t('file_upload.placeholder')} aria-describedby="basic-addon1" onClick={() => { fileRef?.current?.click?.(); }} /> </InputGroup> </Form.Group> ); }; export default CustomFileInput; ` ` <CustomFileInput value={link.value} onChange={onUpload} isInvalid={currentTab === 'localImage' && link.isInvalid} /> {/* <Form.Control type="file" placeholder="123" prefix="234" title="title" onChange={onUpload} isInvalid={currentTab === 'localImage' && link.isInvalid} /> */} ` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
