User tests: Successful: Unsuccessful:
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.
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!:"
/>
Start typing in the text field. Nothing happens.
But when clicking outside the textfield, or hitting tab, the note shows.
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.
Status | New | ⇒ | Pending |
Category | ⇒ | JavaScript |
Noted.
I have tested this item
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.
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
RTC
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?
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?
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.
Any reason why this isn't merged yet?
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.
Ok, thanks :)
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:
?
|
I stand by my previous comments in #22890