Describe the bug
When opening a new page in a form, the first question is automatically focused on. When that question is a date (or dateTime) question, this will cause the bootstrap datepicker popover to open. Depending on the other content in the form, the popover might even cover up the actual label for the question:
To Reproduce
Create a form with some date questions that are the first (or only) questions on the page:
type
name
label::en
date
date_1
First Date
date
date_2
Second Date
Open the form and navigate to the next page
See the datepicker open automatically
Expected behavior
Focusing on the first question makes sense, but opening the datepicker before you even have a chance to read the question is not a great experience. I think it would make more sense to keep the datepicker closed at first, but then be able to open it by selecting the question (or hitting tab if navigating the form via a keyboard).
I am not a bootstrap expert, but it seems like there is no support currently for defining the on-focus behavior. On StackOverflow, I found a suggestion to just automatically hide the popover after the focus event.
_setFocusHandler($fakeDateI) {
// Handle focus on original input (goTo functionality)
$(this.element).on('applyfocus', () => {
$fakeDateI[0].focus();
// Do not automatically pop open the date picker when just focusing on outer element
$fakeDateI.datepicker('hide');
$fakeDateI.blur();
});
}
Describe the bug When opening a new page in a form, the first question is automatically focused on. When that question is a
date
(ordateTime
) question, this will cause the bootstrap datepicker popover to open. Depending on the other content in the form, the popover might even cover up the actual label for the question:To Reproduce
date
questions that are the first (or only) questions on the page:Expected behavior Focusing on the first question makes sense, but opening the datepicker before you even have a chance to read the question is not a great experience. I think it would make more sense to keep the datepicker closed at first, but then be able to open it by selecting the question (or hitting
tab
if navigating the form via a keyboard).I am not a bootstrap expert, but it seems like there is no support currently for defining the on-focus behavior. On StackOverflow, I found a suggestion to just automatically hide the popover after the focus event.
Hacking around with this locally, I was able to get my desired behavior by updating the
DatePickerExtended._setFocusHandler
function to look like this:Not sure if this is the best approach though....
Browser and OS:
Additional context
I can re-create the behavior out on https://getodk.org/xlsform/