? ? Pending

User tests: Successful: Unsuccessful:

avatar hans2103
hans2103
25 Sep 2020

Pull Request for Issue #30759 .

Summary of Changes

When styling the messages and spacing around it I would like to be able to hide the message box when empty using the following CSS. It is clean, it is simple...

#system-message:empty {
    display: none;
}

Because the opening of PHP starts on a new line there is some obsolete spacing rendered.
The CSS statement above is not working due to these obsolete space characters.
When PR is merged the empty message box will appear together with its spacing.
This PR moves the rendering of the joomla-alert to its own JLayout.
The idea behind this is that <div id="system-message"><?php echo $output; ?></div> can be a oneliner which collapses to the AFTER result when rendered empty.

Testing Instructions

  • Joomla 4 install
  • Inspect element

Actual result BEFORE applying this Pull Request

<div id="system-message">
			</div>

Expected result AFTER applying this Pull Request

<div id="system-message"></div>

Documentation Changes Required

avatar hans2103 hans2103 - open - 25 Sep 2020
avatar hans2103 hans2103 - change - 25 Sep 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 25 Sep 2020
Category Layout
avatar HLeithner
HLeithner - comment - 25 Sep 2020

I don't see much benefit from this except if you want to style your system messages different you have to override multiple files

avatar zero-24
zero-24 - comment - 25 Sep 2020

Do you? You can still just override the first and dont load the seccond one in that override right?

avatar hans2103
hans2103 - comment - 25 Sep 2020

The benefit is having <div id="system-message"></div> in your html instead of <div id="system-message"> </div>
The difference is the appearance of obsolete spacing.
And due to this obsolete spacing a simply hide using #system-message:empty {display: none;} cannot be done. The obsolete spacing makes the element not empty.

avatar HLeithner
HLeithner - comment - 25 Sep 2020

Just fix fix the markup in the first file. But creating an additional file for only copy the content to the new file doesn't make much sense to me.

avatar hans2103 hans2103 - change - 25 Sep 2020
Labels Added: ?
avatar hans2103
hans2103 - comment - 25 Sep 2020

@HLeithner sorry... I had no intention to add the extra tabs at the beginning of the file. They have been removed with commit 1ce10bb

But the onliner <div id="system-message"><?php echo $output; ?></div> is needed to get <div id="system-message"></div> while respecting Joomla Code Style

avatar hans2103
hans2103 - comment - 25 Sep 2020

Thank you @HLeithner for the suggestion of this easy solution. ?

avatar brianteeman
brianteeman - comment - 25 Sep 2020

Could you update the title please

avatar SharkyKZ
SharkyKZ - comment - 25 Sep 2020

JS needs updating.

Though I don't think is a good idea at all. Relying on markup to contain/not contain whitespaces is too volatile. Wouldn't use :empty until it supports whitespaces.

avatar hans2103 hans2103 - change - 25 Sep 2020
Title
move joomla-alert from message to it's own JLayout
add else statement to render message container without obsolete spaces
avatar hans2103 hans2103 - edited - 25 Sep 2020
avatar hans2103
hans2103 - comment - 25 Sep 2020

:empty that matches whitespace is not in any browser at the moment.
https://caniuse.com/mdn-css_selectors_empty_matches_whitespace

Though this simple else statement can help frontenders to get rid of obsolete margins.

.container-component {
  > * {
    margin-bottom: 0;
  }
  
  > * + * {
    margin-top: 1.5rem;
  }
}

#system-message:empty {
  display: none;
}

please consider merging this PR. It will benefit styling

avatar hans2103 hans2103 - change - 25 Sep 2020
Title
add else statement to render message container without obsolete spaces
[4.0] Add else-statement to render message container without obsolete spaces
avatar hans2103 hans2103 - edited - 25 Sep 2020
avatar SharkyKZ
SharkyKZ - comment - 25 Sep 2020

:empty that matches whitespace is not in any browser at the moment.
https://caniuse.com/mdn-css_selectors_empty_matches_whitespace

Yes, I know.

avatar hans2103
hans2103 - comment - 25 Sep 2020

The implementation of :empty allowing whitespace is not even close. In the meanwhile we can make Joomla for everyone and merge this PR. A lot of frontend developers would benefit.

JS needs updating.

@SharkyKZ can you explain this? Where and why does JS need to be updated?

avatar HLeithner
HLeithner - comment - 25 Sep 2020

Btw, we have code in mod_menu (maybe not anymore) with a comment that the markup shouldn't have any whit-spaces.

If needed ok but if not really necessary I'm not sure we should rely on such restriction.

avatar HLeithner
HLeithner - comment - 25 Sep 2020

maybe it would better to set a class if empty and a class if content is added with js?

avatar hans2103
hans2103 - comment - 25 Sep 2020

@HLeithner fine by me... If I just can remove spacing when there are no alerts to be shown.
But changing js depends on js, while this PR only relies on PHP

please make a PR on mine with your suggested change

avatar SharkyKZ
SharkyKZ - comment - 25 Sep 2020

The implementation of :empty allowing whitespace is not even close. In the meanwhile we can make Joomla for everyone and merge this PR. A lot of frontend developers would benefit.

JS needs updating.

@SharkyKZ can you explain this? Where and why does JS need to be updated?

When you close the messages, the div contains whitespaces.

avatar hans2103
hans2103 - comment - 25 Sep 2020

@SharkyKZ So the suggestion of @HLeithner to toggle a className when messages are shown or not is an option?
I don't have enough JS skills to do so, if you and / or @HLeithner can help me with it. Would be helpful.

avatar ceford ceford - test_item - 26 Sep 2020 - Tested successfully
avatar ceford
ceford - comment - 26 Sep 2020

I have tested this item successfully on e440e42

If the system message container is empty why is it rendered at all?

  <div id="system-message-container" aria-live="polite">
  	<div id="system-message"></div>
  </div>

I don't see any visible differences in front or back-end (in Firefox/Mac).


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

avatar adj9
adj9 - comment - 26 Sep 2020

I can't find the page to inspect HTML on. Can you point it out to me?

From the path code is better, having good HTML creates a good DOM tree for JS.

avatar SharkyKZ
SharkyKZ - comment - 28 Sep 2020

@SharkyKZ So the suggestion of @HLeithner to toggle a className when messages are shown or not is an option?
I don't have enough JS skills to do so, if you and / or @HLeithner can help me with it. Would be helpful.

It's one of the options. But have you considered not using wildcard selector everywhere? Or changing Cassiopeia markup to match your CSS code?

system-message selector isn't used in JS or in our new templates (only in system ) so could probably be removed.

avatar hans2103
hans2103 - comment - 30 Sep 2020

I have considered not using the wildcard selector. But it seems better to have proper HTML instead of fixing things with more css or javascript. The current HTML adds an obsolete space. It would be nice if we can solve the obsolete space

avatar Scrabble96
Scrabble96 - comment - 1 Oct 2020

I have tested this PR and it still shows a margin-top of 15px, as per my issue mentioned by @richard67 ? joomla/cassiopeia#159

avatar Scrabble96
Scrabble96 - comment - 1 Oct 2020

Sorry. Deleted that comment about mod positions

avatar JazParkyn JazParkyn - test_item - 17 Oct 2020 - Tested successfully
avatar JazParkyn
JazParkyn - comment - 17 Oct 2020

I have tested this item successfully on e440e42


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

avatar richard67 richard67 - change - 17 Oct 2020
Status Pending Ready to Commit
avatar richard67
richard67 - comment - 17 Oct 2020

RTC


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

avatar HLeithner
HLeithner - comment - 17 Oct 2020

This PR is a bit useless because of the reason sharky stated...

avatar richard67
richard67 - comment - 17 Oct 2020

This PR is a bit useless because of the reason sharky stated...

@HLeithner So what to do? Remove RTC?

avatar HLeithner
HLeithner - comment - 17 Oct 2020

decision would be better, hans are you able to modify the alert javascript code to add/remove the class I mentioned and also add it to the php output in this PR?

avatar hans2103 hans2103 - change - 17 Oct 2020
Labels Added: ?
avatar hans2103
hans2103 - comment - 17 Oct 2020

@HLeithner @richard67 I would like to try to prevent adding javascript.
I have adjusted the PR so all echo HTML will be placed directly after each other. When code is added or removed using javascript all code still stick to each other without obsolete spacing.

avatar richard67
richard67 - comment - 17 Oct 2020

@hans2103 Maybe you should change the title and description of this PR because there isn't any "else" statement anymore.

avatar hans2103 hans2103 - change - 17 Oct 2020
Title
[4.0] Add else-statement to render message container without obsolete spaces
[4.0] wrap message container output in an array and implode it so it prevents obsolete spaces
avatar hans2103 hans2103 - edited - 17 Oct 2020
avatar HLeithner
HLeithner - comment - 18 Oct 2020

@HLeithner @richard67 I would like to try to prevent adding javascript.
I have adjusted the PR so all echo HTML will be placed directly after each other. When code is added or removed using javascript all code still stick to each other without obsolete spacing.

What I (and sharky) wanted to say is that the system-messages are also handled in Javascript https://github.com/joomla-projects/custom-elements/blob/master/src/js/alert/alert.js

@SharkyKZ
When you close the messages, the div contains whitespaces.

so if you clean the PHP code you will still have a whitespace explained by skarky (didn't tested it my self)

avatar hans2103
hans2103 - comment - 18 Oct 2020

so if you clean the PHP code you will still have a whitespace explained by skarky (didn't tested it my self)

I don't think so.
The error output generated by my PR is as follows

<div id="system-message-container" aria-live="polite"><div id="system-message"><joomla-alert type="error" dismiss="true"><div class="alert-heading"><span class="error"></span><span class="sr-only">error</span></div><div class="alert-wrapper"><div class="alert-message">**some kind of error message**</div></div></joomla-alert></div></div>

When the message is removed by clicking the x the entire block will collapse to:

<div id="system-message-container" aria-live="polite"></div>

(I have tested this)

As you can see there is no obsolete space within this element. And that is what I want to achieve. No obsolete space.
And this can be achieved without adding javascript

avatar Quy
Quy - comment - 19 Oct 2020

To reproduce, edit/save an article.

30760

avatar hans2103
hans2103 - comment - 21 Oct 2020

@Quy
solved the issue with commit 88f1568 by changing

$msgOutput[] = '<joomla-alert type="' . $alert[$type] ?? $type . '" dismiss="true">';

into

$msgOutput[] = '<joomla-alert type="' . ($alert[$type] ?? $type) . '" dismiss="true">';
avatar Quy Quy - change - 21 Oct 2020
Status Ready to Commit Pending
avatar hans2103 hans2103 - change - 21 Oct 2020
Labels Removed: ?
avatar richard67
richard67 - comment - 21 Oct 2020
avatar hans2103
hans2103 - comment - 21 Oct 2020

I see the message... but there are no JS changes in this PR.

avatar richard67
richard67 - comment - 21 Oct 2020

@hans2103 Maybe it helps if you update the branch to latest 4.0-dev?

avatar hans2103
hans2103 - comment - 21 Oct 2020

merged with latest changes from 4.0-dev

avatar richard67
richard67 - comment - 21 Oct 2020

merged with latest changes from 4.0-dev

Seems it helped ?

avatar Quy Quy - test_item - 21 Oct 2020 - Tested successfully
avatar Quy
Quy - comment - 21 Oct 2020

I have tested this item successfully on c498183


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

avatar drmenzelit drmenzelit - test_item - 21 Oct 2020 - Tested successfully
avatar drmenzelit
drmenzelit - comment - 21 Oct 2020

I have tested this item successfully on c498183


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

avatar Quy Quy - change - 21 Oct 2020
Status Pending Ready to Commit
avatar Quy
Quy - comment - 21 Oct 2020

RTC


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

avatar richard67 richard67 - change - 21 Oct 2020
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2020-10-21 19:17:09
Closed_By richard67
Labels Added: ?
avatar richard67 richard67 - close - 21 Oct 2020
avatar richard67 richard67 - merge - 21 Oct 2020
avatar richard67
richard67 - comment - 21 Oct 2020

Thanks!

avatar SharkyKZ
SharkyKZ - comment - 21 Oct 2020

?‍♂️

avatar richard67
richard67 - comment - 21 Oct 2020

@SharkyKZ It's bad? Have I missed some open discussion? If so, could you make a new issue for it?

avatar richard67
richard67 - comment - 21 Oct 2020

Hmm, I see, it was hidden by default because too long comment history.

@HLeithner Shall we roll back?

avatar hans2103
hans2103 - comment - 21 Oct 2020

@SharkyKZ wrote: #30760 (comment)

system-message selector isn't used in JS or in our new templates (only in system ) so could probably be removed.

In Joomla 3 the file media/plg_installer_webinstaller/js/client.js line 81 makes a reference to #system-message.
And there are some css references to this id.

In Joomla 4 there is no Javascript reference to #system-message anymore.
Might this div element with id = system-message be obsolete?
I'll create a new PR to perform some house cleaning.

avatar hans2103
hans2103 - comment - 21 Oct 2020

PR #31195 created to remove obsolete div element with id = system-message and remove obsolete css referring to this element.

Add a Comment

Login with GitHub to post a comment