-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Fix color field attributes onchange and required. #30743
Fix color field attributes onchange and required. #30743
Conversation
You can never escape git blame 😔. I really don't remember what these 2 attributes are doing but the script docs gives some hints:
Please check the docs, I might got it wrong https://labs.abeautifulsite.net/jquery-minicolors/#settings |
Co-authored-by: Quy <[email protected]>
@dgrammatiko Okay, thank you! I'll look into it tomorrow. |
Updated the docblock accordingly. The other open issue ( |
*/ | ||
|
||
$class = ' class="' . trim('simplecolors chzn-done ' . $class) . '"'; | ||
$disabled = $disabled ? ' disabled' : ''; | ||
$readonly = $readonly ? ' readonly' : ''; | ||
$required = $required ? ' required aria-required="true"' : ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The aria-required="true"
attribute is no longer required.
@@ -65,6 +67,8 @@ | |||
$readonly = $readonly ? ' readonly' : ''; | |||
$hint = strlen($hint) ? ' placeholder="' . $this->escape($hint) . '"' : ' placeholder="' . $placeholder . '"'; | |||
$autocomplete = ! $autocomplete ? ' autocomplete="off"' : ''; | |||
$required = $required ? ' required aria-required="true"' : ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The aria-required="true"
attribute is no longer required.
@thednp hey, quick question: did you manage to get that wasm scss compiler working? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some cleanup needed. I hope devs push this to J4.x as well.
Yes man, thank you for asking. It was a lot of PHP "autoresolve" work. |
The reason I asked you was a recent discussion at #35403 |
Once you're ready let me know and I'll give it a test |
I'm using your sass.js implementation with a custom script to run via a blank custom field and works excellent, the only caveat is file names: if multiple files in multiple locations have same name, it might skip some of them in the auto-resolve process, other than that, it's alright. So yea, I'm not going for the scssphp implementation any time soon, as you nicely advised (thanks). |
@thednp Is this PR okay other than your suggested changes? Changes in v3.10 will be upmerged into v4. |
*/ | ||
|
||
$class = ' class="' . trim('simplecolors chzn-done ' . $class) . '"'; | ||
$disabled = $disabled ? ' disabled' : ''; | ||
$readonly = $readonly ? ' readonly' : ''; | ||
$required = $required ? ' required aria-required="true"' : ''; | ||
$onchange = $onchange ? ' onchange="' . $onchange . '"' : ''; | ||
|
||
// Include jQuery | ||
JHtml::_('jquery.framework'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JHtml::_('jquery.framework');
This is surely different in J4.0
@@ -9,40 +9,42 @@ | |||
|
|||
defined('_JEXEC') or die; | |||
|
|||
use Joomla\CMS\Language\Language; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why add this here? I don't think it's used anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it was autamatically added by the IDE due to
* @var Language $lang Language that is active on the site.
@Quy if my concerns get resolved, all should be fine, I even tested the changes in regards to "onchange", successfully. |
@thednp The author appears to be inactive on GitHub so if no response in a few days, then I will make the changes. Thank you so much for your feedback!! |
@dgrammatiko do you think dart.sass would work instead of sass.js by medialize? In my initial impression, I might need some webpack action to create a bundle similar to the one by medialize. Your thoughts? |
@thednp it should, but I haven't tried it. And yes you will need some sort of bundler (I'm in favor of Rollup as their docs are way more approachable and also it's a better bundler for most use cases) |
I've done some tests into it and haven't managed to get to "consume" the node modules and expose them for web, I used the ESM ( |
@thednp I think dart sass is not yet ready for the browser: sass/dart-sass#25 (comment) so for the time stay with sass.js: medialize/sass.js#135 Also, there are some other side projects from the (dart) team so it might be a browser-ready version there, check their repo's and their branches... |
I already checked that (sass/dart-sass#25 (comment)), however, even if I change files manually and replace all I actually don't know how to bundle npm modules together the way I manage to do with ES6+ modules. |
@dgrammatiko @thednp can you please confirm what the status here is and whether it should be better closed here and moved to j4 as mentiond inline there are some changes between j3 and j4 already. |
Will close here for now. Thanks for the work done here :) |
Summary of Changes
onchange
andrequired
for the color form field.Testing Instructions
type="color"
. Add the attributesrequired
and/oronchange
. Test with both color field layouts (control="simple"
for the simple version).Alternatively, you can use the demo plugin at https://github.com/Harmageddon/plg_demo_colorfield
required
attribute: Try saving the form without entering a value in the required color field.onchange
attribute: Select a value for the field that has theonchange
attribute and see whether the JavaScript handler is called.Actual result BEFORE applying this Pull Request
The values for the two attributes are printed directly in the source code, leading to invalid HTML like:
The onchange handler is not executed.
Required fields don't get the
required
attribute, neither thearia-required="true"
attribute.Expected result AFTER applying this Pull Request
Onchange handlers are executed correctly. Required fields get the
required
attribute.Documentation Changes Required
The documentation of the color form field is very rudimentary and doesn't mention most of the available attributes. It should be improved overall.
Open Issues
required
attribute still has no effect for the simple color picker variant. The reason is that the empty value is not an empty string, but'none'
, which counts as a value both for server-side and client-side validation. I'm not sure how to fix this.I also fixed the documentation in the PHP code of the layouts files. For$control
and$position
, the original description was copy-pasted, so it should be changed to something more meaningful. However, I'm not sure about a good description here. Maybe @dgrammatiko can help here, as you created these layouts?