Skip to content

Commit ad6e7a4

Browse files
committed
5.1.5
1 parent f130cb8 commit ad6e7a4

5 files changed

Lines changed: 45 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
## [5.1.4] - 2026-07-01
5+
## [5.1.5] - 2026-07-01
66

77
### Changed
88
- Default interaction changed: focusing the input (for example via Tab) no longer opens the calendar automatically.
99
- Added option `focusOpens` (default `false`) to opt in to the previous focus-to-open behavior when needed.
1010

11+
### Fixed
12+
- Mobile date and datetime selection no longer forces input focus before opening the native picker, preventing the on-screen keyboard from appearing unnecessarily.
13+
- Time-only mobile inputs (`enableTime=true` and `noCalendar=true`) keep focus behavior so direct time entry still works.
14+
1115
## [5.1.3] - 2026-05-22
1216

1317
### Fixed

__tests__/src/index.spec.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,6 +1437,37 @@ describe("flatpickr", () => {
14371437
plugins: [confirmDatePlugin({})],
14381438
});
14391439
});
1440+
1441+
it("open() does not focus mobile date input", () => {
1442+
mockAgent = "Android";
1443+
createInstance();
1444+
1445+
const mobileInput = fp.mobileInput as HTMLInputElement;
1446+
const focusSpy = jest.spyOn(mobileInput, "focus");
1447+
const clickSpy = jest.spyOn(mobileInput, "click");
1448+
1449+
fp.open();
1450+
1451+
expect(focusSpy).not.toHaveBeenCalled();
1452+
expect(clickSpy).toHaveBeenCalled();
1453+
});
1454+
1455+
it("open() keeps focus for mobile time-only input", () => {
1456+
mockAgent = "Android";
1457+
createInstance({
1458+
enableTime: true,
1459+
noCalendar: true,
1460+
});
1461+
1462+
const mobileInput = fp.mobileInput as HTMLInputElement;
1463+
const focusSpy = jest.spyOn(mobileInput, "focus");
1464+
const clickSpy = jest.spyOn(mobileInput, "click");
1465+
1466+
fp.open();
1467+
1468+
expect(focusSpy).toHaveBeenCalled();
1469+
expect(clickSpy).toHaveBeenCalled();
1470+
});
14401471
});
14411472
});
14421473

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "a11y_datetime",
3-
"version": "5.1.4",
3+
"version": "5.1.5",
44
"description": "Accessible datetime picker based on flatpickr",
55
"scripts": {
66
"build": "run-s build:pre build:build build:esm build:types build:post",

src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2140,6 +2140,9 @@ function FlatpickrInstance(
21402140
positionElement = self._positionElement
21412141
) {
21422142
if (self.isMobile === true) {
2143+
const isTimeOnlyInput =
2144+
self.config.enableTime === true && self.config.noCalendar === true;
2145+
21432146
if (e) {
21442147
e.preventDefault();
21452148
const eventTarget = getEventTarget(e);
@@ -2149,7 +2152,9 @@ function FlatpickrInstance(
21492152
}
21502153

21512154
if (self.mobileInput !== undefined) {
2152-
self.mobileInput.focus();
2155+
if (isTimeOnlyInput) {
2156+
self.mobileInput.focus();
2157+
}
21532158
self.mobileInput.click();
21542159
}
21552160

0 commit comments

Comments
 (0)