? Success

User tests: Successful: Unsuccessful:

avatar regularlabs
regularlabs
2 Nov 2018

Summary of Changes

This PR will make elements show/hide when typing in a text field.

Currently, the showon elements are only updated when the value of a field changes (onChange).
However, when typing in a text field, the change event is only triggered when the focus is moved to another element.

So the PR changes that behaviour to also update the showon fields when the keyup event is triggered.

Testing Instructions

Add this code to a form xml file (inside a fieldset).
We'll use the banners config file for this example:
administrator/components/com_banners/config.xml

<field name="my_text_field" type="text" label="My Text Field" />
<field name="my_note" type="note" class="alert alert-success"
	   description="Shows when the text field is not empty"
	   showon="my_text_field!:"
/>

Before PR

Start typing in the text field. Nothing happens.
But when clicking outside the textfield, or hitting tab, the note shows.
before

After PR

Start typing in the empty text field.
The note shows as soon as it is not empty.
The note also hides again as soon as you delete the characters in the text field.
after

avatar regularlabs regularlabs - open - 2 Nov 2018
avatar regularlabs regularlabs - change - 2 Nov 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 2 Nov 2018
Category JavaScript
avatar brianteeman
brianteeman - comment - 2 Nov 2018

I stand by my previous comments in #22890

avatar regularlabs
regularlabs - comment - 2 Nov 2018

Noted.

avatar ciar4n
ciar4n - comment - 3 Nov 2018

I have tested this item successfully on 9246331

Just to mention.. currently, if a user fills a field that triggers the display of another and goes on to click an action that closes (eg Save and Close), that field may never be seen. This PR fixes that.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/22912.

avatar ciar4n ciar4n - test_item - 3 Nov 2018 - Tested successfully
avatar Quy
Quy - comment - 4 Nov 2018

I have tested this item successfully on 9246331


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/22912.

avatar Quy Quy - change - 4 Nov 2018
Status Pending Ready to Commit
avatar Quy Quy - test_item - 4 Nov 2018 - Tested successfully
avatar Quy
Quy - comment - 4 Nov 2018

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/22912.

avatar tonypartridge
tonypartridge - comment - 6 Nov 2018

I can see this causing havoc on bigger forms with the whole page jumping around when typing.

Can we adjust this so it’s an exact match value? So if value = Goodbar only match on Goodbar.

Or at the very least make it a field value option to toggle on/off?

avatar regularlabs
regularlabs - comment - 6 Nov 2018

The fields will only show if it matches whatever you put into the check. The same way it works for any other field.
Why would it be jumping? It doesn't close and open fields after every keypress. As you can see in the example given.
Also it is up to the developer on how to use this (using showon on text fields). So how could this cause havoc?

avatar tonypartridge
tonypartridge - comment - 6 Nov 2018

Ahh sorry I’ve just checked the code as was on my mobile last night, I assumed looking at the video you were showing on value = foobar . And it was revealing on f etc.

avatar regularlabs
regularlabs - comment - 15 Nov 2018

Any reason why this isn't merged yet?

avatar mbabker
mbabker - comment - 15 Nov 2018

I've purposefully held off on anything that looked feature-esque just to be safe in case something came up warranting 3.9.1 be released sooner than expected. I'll merge your PRs over the weekend assuming nothing comes up before then.

avatar regularlabs
regularlabs - comment - 15 Nov 2018

Ok, thanks :)

avatar mbabker mbabker - change - 17 Nov 2018
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2018-11-17 17:30:40
Closed_By mbabker
Labels Added: ?
avatar mbabker mbabker - close - 17 Nov 2018
avatar mbabker mbabker - merge - 17 Nov 2018

Add a Comment

Login with GitHub to post a comment