Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions build/media_source/system/js/showon.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@ class Showon {
}
});
}
if (this.fields[showonData[0].field] && !this.fields[showonData[0].field].origin.length) {
field.classList.add('hidden');
field.dispatchEvent(new CustomEvent('joomla:showon-hide', {
bubbles: true,
}));
Comment on lines +90 to +93
Copy link
Contributor

@LadySolveig LadySolveig Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
field.classList.add('hidden');
field.dispatchEvent(new CustomEvent('joomla:showon-hide', {
bubbles: true,
}));
field.dispatchEvent(new CustomEvent('joomla:showon-hide', {
detail: {reason: 'missingParent'}
bubbles: true,
}));

Just a suggestion.
Related comment: #46488 (comment)
What do you think, @Fedik @dgrammatiko would it make sense to have a separate event here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep it minimal. Without extra events.
If you really need to have some flag about missing parent then can do kind of:

field.dispatchEvent(new CustomEvent('joomla:showon-hide', {
  detail: {missingParent: true}
  bubbles: true,
}));

Or:

detail: {reason: 'missingParent'}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice thanks for the suggestion.

You would then leave field.classList.add(“hidden”); in place?
Even if that means that in a condition such as, for example, foo!: or foo!:1 are we more likely risk the undesirable side effect of data loss until the user notices it?

Otherwise, I find the event name somewhat confusing.

I don't think it will ever fit in any direction anyway. The main question is in which direction it could potentially cause more problems. 🙃

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personalty I would not hide the field, only show the warning about misconfiguration.
But if people want we can hide.

There should not be any data lose because it just visual thing and nothing to do with field values.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wasn't sure if I had understood you correctly, but that basically confirms what we discussed earlier.

console.warn(
'[Joomla Showon] Invalid showon configuration:',
'Source field not found:',
showonData[0].field,
'→ Dependent field hidden:',
field
);
}
}
});

Expand Down