No Code Attached Yet
avatar toroworx
toroworx
16 Mar 2022

Issue

As explained in the manual, you can use shown attributes within <option> tags since this PR: #18998
This works for com_config if you try, but it does not (always) work for other components.

Steps to reproduce the issue

  • This does not work, when used with a 'new' component (or e.g. with com_banners for this example), when you follow the directions of the mentioned manual. This is because /media/system/js/showon.min.js is not automatically loaded. I think there's either a bug, or the manual is missing this info.
  • Check Chrome DevTools > Sources > your/site/media/system/js, which should show showon.min.js.
    It's visible at https://website/administrator/index.php?option=com_config. But if you go to https://website/administrator/index.php?option=com_banners&view=banner&layout=edit you'll see showon.min.js is missing.

Steps to fix the issue

Either update the manual or the Joomla code. I don't know what's preferred.
If you'll manually add the following to your existing component's joomla.asset.json:

{
	"name": "showon",
	"type": "script",
	"dependencies": [
		"core",
		"showon.es5"
	],
	"uri": "system/showon.min.js",
	"attributes": {
		"type": "module"
	},
	"version": "bfc733e48a923aaffb3d959cd04f176bad7d7d52"
}

And load this script with the web asset manager:

$wa = $this->document->getWebAssetManager();
$wa->useScript('showon');

Then it should work as expected.

Attention

It's key for this bug report to try the shown feature within an <option> tag, because it does always work within a <field> tag.

System information

Joomla! 4.1.0 Stable

avatar toroworx toroworx - open - 16 Mar 2022
avatar joomla-cms-bot joomla-cms-bot - change - 16 Mar 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 16 Mar 2022
avatar dgrammatiko
dgrammatiko - comment - 16 Mar 2022

Expected behaviour. If you need the showon you have to load the script. Also you don't have to copy the system JSON to your component, just load it directly $this->document->getWebAssetManager()->useScript('showon')

Joomla is not following the old patterns, eg loading JS/CSS global, if the developer needs a specific JS/CSS they have to load it, per instance but this is a bug

avatar dgrammatiko
dgrammatiko - comment - 17 Mar 2022

Please test #37300

avatar richard67 richard67 - close - 17 Mar 2022
avatar richard67
richard67 - comment - 17 Mar 2022

Closing as having a pull request. Please test #37300 . Thanks in advance.

avatar richard67 richard67 - change - 17 Mar 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-03-17 09:30:55
Closed_By richard67
avatar richard67 richard67 - change - 1 Apr 2022
Status Closed New
Closed_Date 2022-03-17 09:30:55
Closed_By richard67
avatar richard67 richard67 - reopen - 1 Apr 2022
avatar richard67
richard67 - comment - 1 Apr 2022

Re-opening as the pull request was closed.

avatar richard67 richard67 - change - 1 Apr 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-04-01 16:37:12
Closed_By richard67
avatar richard67 richard67 - close - 1 Apr 2022
avatar richard67
richard67 - comment - 1 Apr 2022

New PR is #37451 .

Add a Comment

Login with GitHub to post a comment