Repository: Hacker0x01/react-datepicker (ts)

Issue:
Time cannot be set via typing since v6.3.0
**Describe the bug**
Since the update to v6.3.0, we have noticed that when `minTime` is set, it is no longer possible to set the time by typing it into the input field: As soon as the input field loses focus, the time value displayed changes to the given `minTime` value. 

Setting the date via typing still works just fine, as does setting the time by clicking the respective item in the selection list.

It seems that this issue is due to the changes in [this pull request](https://github.com/Hacker0x01/react-datepicker/pull/4552); in particular, when we use a custom version of `react-datepicker` where the following lines in `src/index.jsx` are removed, the issue disappears:

```
// If minTime is present then set the time to minTime
        if (this.props.showTimeSelect || this.props.showTimeSelectOnly) {
          if (minTime) {
            changedDate = setTime(changedDate, {
              hour: minTime.getHours(),
              minute: minTime.getMinutes(),
              second: minTime.getSeconds(),
            });
          }
        }
```

**To Reproduce**
I have prepared [a sandbox with an example datepicker](https://codesandbox.io/p/sandbox/react-datepicker-time-bug-ddgkwx?file=%2Fsrc%2FApp.tsx) that can be used to reproduce the behavior.

Steps to reproduce the behavior:

1. Click into the input field.
2. Replace the current time displayed with any other value (e.g. `10:00`)
3. Click outside of the input field.
4. The time displayed changes to `06:00`, which corresponds to the `minTime` value set in the example.

**Expected behavior**
The time displayed should be the time that the user typed in.

Pull request:
fix: #4588 Allow time to be set via typing when minTime is set
## Description
**Linked issue**: close #4588 

**Problem**
See issue #4588 

**Changes**
Set the selected time to `minTime` only if no input to be kept is present.

## Screenshots
<!-- If applicable, add screenshots to help explain your improvements -->

## To reviewers
<!-- Additional comments for reviewers -->

## Contribution checklist
- [x] I have followed the [contributing guidelines](https://github.com/Hacker0x01/react-datepicker/blob/main/CONTRIBUTING.md).
- [x] I have added sufficient test coverage for my changes.
- [x] I have formatted my code with Prettier and checked for linting issues with ESLint for code readability.


Patch:
diff --git a/src/index.jsx b/src/index.jsx
index 3a89d6fc..e20f8da7 100644
--- a/src/index.jsx
+++ b/src/index.jsx
@@ -657,7 +657,10 @@ export default class DatePicker extends React.Component {
         }
 
         // If minTime is present then set the time to minTime
-        if (this.props.showTimeSelect || this.props.showTimeSelectOnly) {
+        if (
+          !keepInput &&
+          (this.props.showTimeSelect || this.props.showTimeSelectOnly)
+        ) {
           if (minTime) {
             changedDate = setTime(changedDate, {
               hour: minTime.getHours(),


Test patch:
diff --git a/test/min_time_test.test.js b/test/min_time_test.test.js
index 9da15ae3..d8bcbc20 100644
--- a/test/min_time_test.test.js
+++ b/test/min_time_test.test.js
@@ -12,6 +12,7 @@ const DatePickerWithState = (props) => {
         setSelected(date);
       }}
       showTimeSelect
+      dateFormat="MM/dd/yyyy HH:mm"
       {...props}
     />
   );
@@ -46,4 +47,18 @@ describe("Datepicker minTime", () => {
 
     expect(selectedTime.getAttribute("aria-selected")).toBe("true");
   });
+
+  it("should select time from input instead of minimum allowable time when time is typed in", () => {
+    const minTime = new Date("2023-03-10 13:00");
+    const maxTime = new Date("2023-03-10 18:00");
+
+    const { container } = render(
+      <DatePickerWithState minTime={minTime} maxTime={maxTime} />,
+    );
+    const input = container.querySelector("input");
+    fireEvent.change(input, { target: { value: "2023-03-10 16:00" } });
+    fireEvent.focusOut(input);
+
+    expect(input.value).toEqual("03/10/2023 16:00");
+  });
 });