-
Notifications
You must be signed in to change notification settings - Fork 4
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
How to render custom TextInput or RangeDatePicker instead of common Control #158
Comments
Try something like this: const [text, setText] = React.useState('');
return (
<RelativeRangeDatePicker
{...props}
renderControl={({open, title, triggerProps, ref}) => {
return (
<TextInput
ref={ref}
value={open ? title : text}
onUpdate={setText}
readOnly={open}
endContent={
<Button size="s" component="button" {...triggerProps} extraProps={{...triggerProps}}>
<Icon data={Calendar} />
</Button>
}
/>
);
}}
/>
); |
I still can't change the input value, when it's "focused" (the picker modal appears) And need to render picker when I click into TextInput. As I had mentioned at the issue below (second picture) Can edit the input and use modal functionality. Modal should appear not only when I click calendar button, but when I focus the input |
then try to use dialog itself : function DatePicker(props) {
const state = useRelativeRangeDatePickerState(props);
const [open, setOpen] = React.useState(false);
const [text, setText] = React.useState('');
const ref = React.useRef<HTMLElement>(null);
return (
<React.Fragment>
<TextInput
ref={ref}
value={text}
onUpdate={setText}
onFocus={() => {
setOpen(true);
}}
/>
<RelativeRangeDatePickerDialog
anchorRef={ref}
props={props}
state={state}
open={open}
onClose={() => {
setOpen(false);
}}
// added in 2.12.0
disableFocusTrap
/>
</React.Fragment>
);
}, |
At my project I need to use RelativeRangeDatePicker with custom input render to have ability change date manually at TextInput field (or at RangeDatePicker - it is much more comfortable with it's mask for date).
![Screenshot 2025-01-14 at 16 40 49](https://private-user-images.githubusercontent.com/55848388/402940646-b2bc8042-5589-4208-a3f9-fea105eae87f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5MTQ3NDUsIm5iZiI6MTczODkxNDQ0NSwicGF0aCI6Ii81NTg0ODM4OC80MDI5NDA2NDYtYjJiYzgwNDItNTU4OS00MjA4LWEzZjktZmVhMTA1ZWFlODdmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDA3NDcyNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTI1OWU0OGFkNDdhYTdjOGI4OGMwOGU3OTFiYmQ0MjFlOGY5ZTQ1OGQ0MDI1NThhMDMyY2EzZWVkZWU2ZmI2OWYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Rbvy4wACLEI3k20IAYVJBYIiDoqLde6CCXP1uj7CzhE)
I have a problem now, because I can't even enter a number into custom rendered Input.
A simple repro:
Expected result:
![Screenshot 2025-01-14 at 16 42 35](https://private-user-images.githubusercontent.com/55848388/402941775-fd7927e7-cfd5-4018-9af9-f8252a28c41c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5MTQ3NDUsIm5iZiI6MTczODkxNDQ0NSwicGF0aCI6Ii81NTg0ODM4OC80MDI5NDE3NzUtZmQ3OTI3ZTctY2ZkNS00MDE4LTlhZjktZjgyNTJhMjhjNDFjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDA3NDcyNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWY5Y2E2YjVkMDJiODA0NGZkYWY1YmE4NzQ3OTI5ODkwMWMxODJkMmYyNmM4OGQ0ODBjMDg1ZmI5ZDVlNTU2MzImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.9Euc1w1zK5ZbsI8L4HPupxA2fHa6z10cc4kjZUV4Eag)
I can render different node throw renderControl not loosing it's ux and RelativeRangeDatePicker modal functionality which we see on focus.
The text was updated successfully, but these errors were encountered: