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

Date picker fails to appear when field is shown after the page loads #3909

Closed
avernet opened this Issue Jan 24, 2019 · 4 comments

Comments

Projects
2 participants
@avernet
Copy link
Collaborator

avernet commented Jan 24, 2019

@avernet

This comment has been minimized.

Copy link
Collaborator Author

avernet commented Jan 25, 2019

I am using this cleaned-up form.txt. When the date control shows, the server sends an Ajax response with the <xxf:control> quoted below to the client. This is the first time the client is being told anything about date-2-control, which causes the initialization of the control, and this before classes are set on the control, which leads to a similar result than #3888, but in this case we have no <xxf:init> in the Ajax response. This seems to be a problem on the server: reassigning to @ebruchez.

<xxf:control id="section-1-section≡grid-1-grid≡date-2-control" label="Date" hint="" relevant="true">
    <xxf:value />
</xxf:control>

@avernet avernet assigned ebruchez and unassigned avernet Jan 25, 2019

@avernet avernet added this to To do in Orbeon Forms 2018.2.1 Jan 25, 2019

@ebruchez

This comment has been minimized.

Copy link
Collaborator

ebruchez commented Feb 1, 2019

To clarify: the field shows, but the picker doesn't when you click on the calendar icon.

@ebruchez ebruchez added this to To review in Orbeon Forms 2019.1 via automation Feb 1, 2019

@ebruchez

This comment has been minimized.

Copy link
Collaborator

ebruchez commented Feb 1, 2019

So this is tricky. The response has:

<xxf:control id="section-1-section≡grid-1-grid≡date-2-control" label="Date" hint="" relevant="true">
    <xxf:value/>
</xxf:control>

relevant="true" causes ORBEON.xforms.Controls.setRelevant() to run, which causes ORBEON.xforms.XBL.instanceForControl(control), which causes init(). But this, again happens before the following markup is processed:

<xxf:control id="section-1-section≡grid-1-grid≡date-2-control≡xf-630" readonly="true" relevant="true"/>
<xxf:control class="input-append date fr-field-width-full" id="section-1-section≡grid-1-grid≡date-2-control≡xf-635"/>
<xxf:attribute for="section-1-section≡grid-1-grid≡date-2-control≡xf-638" name="placeholder">MM/DD/YYYY</xxf:attribute>
@ebruchez

This comment has been minimized.

Copy link
Collaborator

ebruchez commented Feb 1, 2019

What we'd like to achieve in general is that changes to the markup for the control and nested content is processed before the JavaScript lifecycle methods run.

Note that we need xxf:init in full updates because the markup is just set in the page, not updated incrementally. With incremental updates, xxf:init was not needed ' because relevant changes would do the needful. Except, that is, that it happens too early.

If the Ajax response had a nested format, this might help. So instead of:

<xxf:control-values>
    <xxf:control id="xf-291" relevant="true"/>
    <xxf:control id="xf-292" relevant="true"/>
    <xxf:attribute for="xf-293" name="title">Unsaved changes</xxf:attribute>
    <xxf:control id="section-1-section≡grid-1-grid≡date-2-control" label="Date" hint="" relevant="true">
        <xxf:value/>
    </xxf:control>
    <xxf:control id="section-1-section≡grid-1-grid≡date-2-control≡xf-630" readonly="true" relevant="true"/>
    <xxf:control class="input-append date fr-field-width-full" id="section-1-section≡grid-1-grid≡date-2-control≡xf-635"/>
    <xxf:attribute for="section-1-section≡grid-1-grid≡date-2-control≡xf-638" name="placeholder">MM/DD/YYYY</xxf:attribute>
</xxf:control-values>

We'd have:

<xxf:control-values>
    <xxf:control id="xf-291" relevant="true"/>
    <xxf:control id="xf-292" relevant="true"/>
    <xxf:attribute for="xf-293" name="title">Unsaved changes</xxf:attribute>
    <xxf:control id="section-1-section≡grid-1-grid≡date-2-control" label="Date" hint="" relevant="true">
        <xxf:value/>
        <xxf:control id="section-1-section≡grid-1-grid≡date-2-control≡xf-630" readonly="true" relevant="true"/>
        <xxf:control class="input-append date fr-field-width-full" id="section-1-section≡grid-1-grid≡date-2-control≡xf-635"/>
        <xxf:attribute for="section-1-section≡grid-1-grid≡date-2-control≡xf-638" name="placeholder">MM/DD/YYYY</xxf:attribute>
    </xxf:control>
</xxf:control-values>

Having processed the entire content of a control with nested content, the JavaScript lifecycle methods can run:

  • setRelevant
  • setReadonly
  • setCurrentValue

Nesting might be a change a little bit too big for 2018.2.1. If the server could tell us instead when to run those initializations, that would be better. So:

  • If any of relevance, readonliness or value has changed, place an xxf:init element.
  • On the client client, the setRelevant, etc. methods do not handle XBL components.
  • Instead, xxf:init processing does what is needed directly.
<xxf:control-values>
    <xxf:control id="xf-291" relevant="true"/>
    <xxf:control id="xf-292" relevant="true"/>
    <xxf:attribute for="xf-293" name="title">Unsaved changes</xxf:attribute>
    <xxf:control id="section-1-section≡grid-1-grid≡date-2-control" label="Date" hint="" relevant="true">
        <xxf:value/>
    </xxf:control>
    <xxf:control id="section-1-section≡grid-1-grid≡date-2-control≡xf-630" readonly="true" relevant="true"/>
    <xxf:control class="input-append date fr-field-width-full" id="section-1-section≡grid-1-grid≡date-2-control≡xf-635"/>
    <xxf:attribute for="section-1-section≡grid-1-grid≡date-2-control≡xf-638" name="placeholder">MM/DD/YYYY</xxf:attribute>
    <xxf:init id="section-1-section≡grid-1-grid≡date-2-control"/>
</xxf:control-values>

@ebruchez ebruchez closed this in a0f8d7e Feb 1, 2019

Orbeon Forms 2019.1 automation moved this from To review to Done Feb 1, 2019

Orbeon Forms 2018.2.1 automation moved this from To do to Done Feb 1, 2019

ebruchez added a commit that referenced this issue Feb 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment