Comments (1)
My solution:
import React from 'react';
import { DayPicker, useInput } from 'react-day-picker';
import 'react-day-picker/dist/style.css';
export function App() {
const { dayPickerProps, inputProps } = useInput({
defaultSelected: new Date(),
format: 'dd/MM/yyyy',
});
const handleEmpty = ( e ) => {
if ( !e.target.value ) {
return;
}
inputProps.onBlur( e );
};
return (
<div>
<input {...inputProps} onBlur={ handleEmpty } />
<DayPicker {...dayPickerProps} />
</div>
);
}
And this might be the place to add the change to make it happen (useInput.ts:141):
// Special case for _required_ fields: on blur, if the value of the input is not
// a valid date, reset the calendar and the input value.
const handleBlur: FocusEventHandler<HTMLInputElement> = (e) => {
const value = e.target.value;
if(!required && !value.length) {
return;
}
const day = parseValue(value);
if (!isValidDate(day)) {
reset();
}
};
from react-day-picker.
Related Issues (20)
- Bug: onPrevClick and onNextClick does not trigger
- Fix: Docs. Type alias: Matcher api reference page uses incorrect ";" in the examples
- Fix: Contributing.md line about proofreading the website links to an old deploy
- Bug: DayPicker does not automatically navigate to selected date
- Bug: Inline styles are not getting applied as intended, assistance needed please. HOT 1
- Bug: Lag when displaying many months and switching selected date HOT 1
- Bug: Dependency conflict with date-fns version 3.0.1 HOT 3
- Datepicker Allows Selection of Ranges with Disabled Days in Between HOT 1
- showOutsideDays is disabled 1st on month start always on Sunday HOT 1
- Hi! I'm not opening new issue because I think it can be somehow related with this one 🙂 HOT 3
- Disabled days can be selected with selected prop HOT 1
- Can't import the named export 'buildLocalizeFn' from non EcmaScript module (only default export is available)
- Accessibility issue in calendar picker in the latest version 8.10.0
- Bug with label
- Calendar set's date to undefined when same date selected and this give inconsistent behavior! HOT 2
- Safari/iOS: hover background when unselecting a day HOT 4
- [Future Request] Enhancing changes to make React Day Picker responsive
- RootContext is missing pass-through types for each context it provides HOT 6
- toDate and fromDate are not working as expected HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-day-picker.