Skip to content

Commit 02591b0

Browse files
committed
[Fix] Changed readonly to readOnly
[Fix] Stop calendar from showing when `readOnly`
1 parent 693e2b3 commit 02591b0

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/components/Datepicker.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ interface Props {
4747
inputClassName?: string | null;
4848
containerClassName?: string | null;
4949
displayFormat?: string;
50-
readonly?: boolean;
50+
readOnly?: boolean;
5151
}
5252

5353
const Datepicker: React.FC<Props> = ({
@@ -67,7 +67,7 @@ const Datepicker: React.FC<Props> = ({
6767
inputClassName = null,
6868
containerClassName = null,
6969
displayFormat = "YYYY-MM-DD",
70-
readonly = false
70+
readOnly = false
7171
}) => {
7272
// Ref
7373
const containerRef = useRef<HTMLDivElement>(null);
@@ -264,7 +264,7 @@ const Datepicker: React.FC<Props> = ({
264264
disabled,
265265
inputClassName,
266266
containerClassName,
267-
readonly
267+
readOnly
268268
};
269269
}, [
270270
asSingle,
@@ -284,7 +284,7 @@ const Datepicker: React.FC<Props> = ({
284284
disabled,
285285
inputClassName,
286286
containerClassName,
287-
readonly
287+
readOnly
288288
]);
289289

290290
return (

src/components/Input.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const Input: React.FC = () => {
2525
separator,
2626
disabled,
2727
inputClassName,
28-
readonly
28+
readOnly
2929
} = useContext(DatepickerContext);
3030

3131
// UseRefs
@@ -84,7 +84,7 @@ const Input: React.FC = () => {
8484
e.stopPropagation();
8585
if (inputRef?.current) {
8686
inputRef.current.focus();
87-
if (inputText) {
87+
if (inputText && !readOnly) {
8888
changeInputText("");
8989
if (dayHover) {
9090
changeDayHover(null);
@@ -124,7 +124,7 @@ const Input: React.FC = () => {
124124
const arrow = arrowContainer?.current;
125125

126126
function showCalendarContainer() {
127-
if (arrow && div && div.classList.contains("hidden")) {
127+
if (arrow && div && div.classList.contains("hidden") && !readOnly) {
128128
div.classList.remove("hidden");
129129
div.classList.add("block");
130130
// window.innerWidth === 767
@@ -168,7 +168,7 @@ const Input: React.FC = () => {
168168
type="text"
169169
className={getClassName()}
170170
disabled={disabled}
171-
readOnly={readonly}
171+
readOnly={readOnly}
172172
placeholder={
173173
placeholder
174174
? placeholder

src/contexts/DatepickerContext.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ interface DatepickerStore {
3131
disabled?: boolean;
3232
inputClassName?: string | null;
3333
containerClassName?: string | null;
34-
readonly?: boolean;
34+
readOnly?: boolean;
3535
}
3636

3737
const DatepickerContext = createContext<DatepickerStore>({
@@ -59,7 +59,7 @@ const DatepickerContext = createContext<DatepickerStore>({
5959
disabled: false,
6060
inputClassName: "",
6161
containerClassName: "",
62-
readonly: false
62+
readOnly: false
6363
});
6464

6565
export default DatepickerContext;

0 commit comments

Comments
 (0)