-
-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When creating new Health Facility, date picker shows over search box #6486
Comments
I...I think I found the problem? I think I found the problem!! Our forms are structured to use the implicit relationship of a If I go in via the developer tools and delete the first one (which is invisible <input type="date" name="/data/contact/ephemeral_dob/dob_calendar" data-required="true()" data-constraint="floor(decimal-date-time(.)) <= floor(decimal-date-time(today()))" data-relevant="not(selected(../dob_method,'approx'))" data-type-xml="date" style="display: none;"> |
Ah! And I found a possible fix. It appears that the How easy this is to do is another question ;) Onward!! |
I chatted with @SCdF on this and he said that MM uses the bootstrap datepicker b/c it fixes the way older versions of android poorly handle them with the native picker. He was also able to reproduce the error on his FF instance, which is great 💯 He also said that @garethbowen would likely be the best person to follow up on this ;) I checked your calendar and it looks like you're busy today @garethbowen (Jun 19th) - but when ever you get a sec! Edit - And he also every so gently reminded me that today is Sat for you - catch ya next week! |
@mrjones-plip That makes sense to me! Great idea. Essentially clicking on the label focuses on the hidden input which triggers Firefox to show the datepicker. IMO this is a bug in Firefox because it should not be possible to focus on a hidden input. If you felt so inclined you could raise a bug in Firefox. It looks like this code in the enketo-core widget is meant to handle it: https://github.com/enketo/enketo-core/blob/4.41.6/src/widget/date/datepicker-extended.js#L143 . This has changed a little in the latest version of enketo-core so it's possible it'll be fixed when we upgrade, but I can't see any issues in the enketo-core repo about this so probably not... First, double check my assumption that this is the widget that's being used here - we have a few different ones... If it is then the fix is a little difficult because we'd have to patch the enketo-core library. For now, you can investigate the correct solution by copying the enketo-core widget linked above into our code and updating our widget.js to use the copied version instead of the official version. Make sure you copy the right version of the enketo-core widget as we're stuck on 4.41.6 which is quite an old version. Then you can use the normal debugging process to test out ways to reorder the DOM, or change the ID/name of elements, or try and catch the focus, or whatever! Once we've worked out how to solve it we can work out how to get it into the code, either by patching, or extending, or updating enketo-core. |
@garethbowen - whew - this is slow going for this PHP engineer over here ;) I've copied over the enketo core ( require( './enketo-core-clone-testing/widget/date/datepicker-extended' ), The app then devolves as expected to show the native FF datepicker when the dob field gets focus, with no bootstrap UI to be seen. Now on to (slowly) debug how to fix it! |
Oh - that went a lot more quickly than I thought it would! Whew. All we have to do is change line 94 in datepicker-extended.js from this: $dateI.hide().after( $fakeDate ); To this: $dateI.hide().before( $fakeDate ); I'll look into this part now:
|
One way to solve it is simply by committing the copied code. We'd just have to be careful to update it (or hopefully if it's fixed, remove it) when updating enketo-core. |
Yes, for sure including the copied code wholesale would work, as it is in my dev environment now. However, the var Widget = require( '../../js/Widget' );
var support = require( '../../js/support' );
var $ = require( 'jquery' );
var types = require( '../../js/types' );
require( 'bootstrap-datepicker' );
require( '../../js/dropdown.jquery' ); In order to get all those to resolve nicely, I just copied the entire |
Have a look at our other custom widgets in |
Yes, I saw that! More to get confused by ;) I'll pick this up tomorrow - but very much appreciate the hand holding through this! |
@garethbowen - thanks for the tip re FF bug! I just filed a bug with them. An interesting finding is that both Chrome and Safari don't show datepicker but they also do not (visibly?) put the focus on the visible input. For reference the distilled test HTML is: <label>
A label
<input type="date" style="display: none;" >
<input type="text">
</label> I wonder if it the other two browsers are indeed putting the focus on the date input but are simply not showing the datepicker? I'll write some more test code to verify - my gut is saying "yes". A quick test for the form in question in this ticket in chrome reveals that neither datepicker is shown when clicking the the label. Meanwhile all the other labels on this form work as expected. An upstream ticket against enketo is likely warranted too then. |
Yes I think so, however we're on a very old version of Enketo so it'd be good to attempt to reproduce this using the latest version before filing a bug. Plunker is a good site for reproducing bugs and means you can share the reproduction if you do end up raising an Enketo bug. |
Awesome! As always, your guidance is much appreciated. |
OK! I had great luck with how easy it was to reproduce this issue on latest Enketo version using their off the self set up ( So, cool. When I hear back from Enketo I'll report back and we can decide to close or what. |
The Enketo PR was accepted and merged to enketo-core master \o/ closing in favor of the other upgrade cht-core to enketo tickets |
I was setting up my dev environment and went to set up a new health facility. When selecting the age of the new person that's created in the process, I see a seemingly random datepicker appear over the "search everything" box in the upper left of the browser.
To Reproduce
Assuming a totally clean install using localhost:5988, Steps to reproduce the behavior:
A more simple way of reproducing, again assuming an entirely clean install:
question or-branch non-select invalid-required
)This may be systemic: when creating a user when creating a New Area and New Household, the same problem manifested.
Expected behavior
The primary datepicker closes and no secondary datepicker is shown
Logs
I'm not sure if it's related, but the browser console logs show this before interacting with the page:
No further console logs are generated when the secondary datepicker is shown
Screenshots
Environment
Additional context
question or-branch non-select invalid-required
label for the Age field.The text was updated successfully, but these errors were encountered: