Skip to content

Commit 53c26d8

Browse files
committed
[Fix 🐛] The placeholder does not match the displayFormat props .
1 parent ab1d314 commit 53c26d8

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

src/components/Datepicker.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,27 +264,29 @@ const Datepicker: React.FC<Props> = ({
264264
disabled,
265265
inputClassName,
266266
containerClassName,
267-
readOnly
267+
readOnly,
268+
displayFormat
268269
};
269270
}, [
270271
asSingle,
271272
colorPrimary,
272273
configs,
273-
dayHover,
274-
firstGotoDate,
275274
hideDatepicker,
276-
i18n,
275+
period,
276+
dayHover,
277277
inputText,
278278
onChange,
279-
period,
279+
showFooter,
280280
placeholder,
281281
separator,
282-
showFooter,
282+
i18n,
283283
value,
284284
disabled,
285285
inputClassName,
286286
containerClassName,
287-
readOnly
287+
readOnly,
288+
displayFormat,
289+
firstGotoDate
288290
]);
289291

290292
return (

src/components/Input.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ const Input: React.FC = () => {
2525
separator,
2626
disabled,
2727
inputClassName,
28-
readOnly
28+
readOnly,
29+
displayFormat
2930
} = useContext(DatepickerContext);
3031

3132
// UseRefs
@@ -173,7 +174,7 @@ const Input: React.FC = () => {
173174
placeholder={
174175
placeholder
175176
? placeholder
176-
: `YYYY-MM-DD${asSingle ? "" : ` ${separator} YYYY-MM-DD`}`
177+
: `${displayFormat}${asSingle ? "" : ` ${separator} ${displayFormat}`}`
177178
}
178179
value={inputText}
179180
onChange={handleInputChange}

src/contexts/DatepickerContext.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ interface DatepickerStore {
3232
inputClassName?: string | null;
3333
containerClassName?: string | null;
3434
readOnly?: boolean;
35+
displayFormat?: string;
3536
}
3637

3738
const DatepickerContext = createContext<DatepickerStore>({
@@ -59,7 +60,8 @@ const DatepickerContext = createContext<DatepickerStore>({
5960
disabled: false,
6061
inputClassName: "",
6162
containerClassName: "",
62-
readOnly: false
63+
readOnly: false,
64+
displayFormat: "YYYY-MM-DD"
6365
});
6466

6567
export default DatepickerContext;

0 commit comments

Comments
 (0)