Problem/Motivation

When I was working on #2349577: "Edit" button on machine name doesn't disappear at first I discovered in core/misc/machine-name.js three occurrences of .append(' ') (append whitespace). Example:

$suffix.append(' ').append('<span class="machine-name-label">' + options.label + ':</span>');

Proposed resolution

Change .append(' ') to content: ' ['; in system.admin.css (patch #3).
LTR
RTL

Remaining tasks

Replace .append(' ') with CSS style in system.admin.css.
Review and commit.

User interface changes

API changes

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task
Prioritized changes The main goal of this issue is simplification of Javascript to make code more maintainable

Comments

zaporylie’s picture

Title: Change .append(' ') with CSS style in system.theme.css » Change .append(' ') with CSS style in system.admin.css
Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new2.09 KB
new41.61 KB
new41.96 KB
new29.78 KB
new21.57 KB

I've attached initial patch to fix this issue, and some screens to summary. Also changed system.theme.css to system.admin.css which seems to be better place.

gaurav.goyal’s picture

StatusFileSize
new183.2 KB
new174.76 KB
new77.48 KB

Upon manual review patch looks good to me, Attached are the screen shots.

checked for the following

1. Different screen sizes
2. Different types of fields, taxonomies, content types.

#1 Works for for me

droplet’s picture

StatusFileSize
new1.65 KB

Why not append the SPACE ?

zaporylie’s picture

I believe this is also a good way to solve issue but you should definitely support RTL users in your CSS.

mcdruid’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new2.1 KB

Looking at the change record for "Use [dir="rtl"] in stylesheets" https://www.drupal.org/node/2032405 it looks like the CSS has been written appropriately, with the very small exception of whitespace in the LTR comments.

New patch to address that very minor whitespace in the CSS comments issue.

Other than that, RTBC.

droplet’s picture

Component: javascript » CSS
Status: Reviewed & tested by the community » Needs review

#5 is diff to my one on #3. Back to Needs review for another reviewer.

My last testing on #3 Patch is working on RTL as well. Personally, I love my patch, more simpler :)

Thanks.

mcdruid’s picture

@droplet it seems redundant to me to be moving the addition of whitespace characters from the JS to the CSS. If this is a layout issue, I'd have thought it better to do the layout via margins / box model rather than the addition of space characters to the HTML, regardless of the mechanism by which they're inserted between pieces of content.

However, it's been a while since I did much front-end.

Also, your #3 patch removed the space being appended before the preview:

-        $suffix.append(' ').append($preview);
+        $suffix.append($preview);

...but this is not added back in by CSS. Instead you've added it to string after the closing span tag:

-          $suffix.append(' ').append('<span class="machine-name-label">' + options.label + ':</span>');
+          $suffix.append('<span class="machine-name-label">' + options.label + ':</span> ');

To me that reinforces the suggestion that your approach is just rearranging the way that whitespace characters are added between the text elements.

Therefore the original approach of removing the whitespace characters altogether and implementing the layout via "pure" CSS would get my vote.

jhedstrom’s picture

Issue summary: View changes
Status: Needs review » Needs work

I think this is at needs work per #7. I've taken a stab at the beta phase evaluation in the issue summary.

jhedstrom’s picture

Status: Needs work » Needs review

Er, wait, I got confused. This is still at needs review. I tend to agree that #5 makes sense, rather than adding more spaces in the JS as #3 does.

Status: Needs review » Needs work

The last submitted patch, 5: change_append-2360175-5.patch, failed testing.

zaporylie’s picture

Issue tags: +Needs reroll
pushpinderchauhan’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new2.08 KB

Rerolled.

droplet’s picture

Status: Needs review » Needs work

errors on machine name, please check: admin/structure/types/add

sivaji_ganesh_jojodae’s picture

#13 looks fine to me. Patch applies cleanly and no errors on machine name at admin/structure/types/add.

droplet’s picture

StatusFileSize
new7.2 KB

*** To remember clean caches after patching

sivaji_ganesh_jojodae’s picture

Status: Needs work » Needs review
StatusFileSize
new2.03 KB

@droplet, thank you.

Removing float seems to fix the issue. Patch attached.

droplet’s picture

Status: Needs review » Reviewed & tested by the community

although i like my own way, it's patch still looks good and no reason not let it go ahead :)

sivaji_ganesh_jojodae’s picture

Thanks for the RTBC.

Regarding #3,

@@ -79,7 +79,7 @@ div.admin .expert-link {
  * Quick inline admin links.
  */
 small .admin-link:before {
-  content: '[';
+  content: ' [';
 }

IMO the space before [ will certainly make someone wonder so I prefer not to go for it.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 17: change_append-2360175-17.patch, failed testing.

Status: Needs work » Needs review
tadityar’s picture

Status: Needs review » Reviewed & tested by the community

It's a re-roll, passed, and was RTBC-ed before, so re-up RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 17: change_append-2360175-17.patch, failed testing.

Status: Needs work » Needs review
tadityar’s picture

Status: Needs review » Reviewed & tested by the community

Passed again, RTBC again.

alexpott’s picture

Status: Reviewed & tested by the community » Needs review

I'm not that convinced by this issue. We're building text here that is meant to be read as a sentence - the space has a semantic meaning when placed between words.

I think the use of .append(' ') is acceptable and denotes that it is intended - since it would be possible to add the space into the variables if we want.

Tempted to mark "Closed - works as designed" but will punt back to needs review for further consensus building.

nod_’s picture

I'm not comfortable with creating a space using margins (partly due to the fact that I'm not sure we can replicate exactly the size of the space character with margins).

I like the solution in #3 as well, the extra characters are added from there as well, makes sense to have the spacing done at the same place.

lewisnyman’s picture

Issue tags: +CSS

Yeah the solution in #3 makes more sense to me. The space added in CSS should get picked up by screen readers.

lewisnyman’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #3 still applies so knocking back to RTBC so Alex can weigh in.

zaporylie’s picture

I made some changes in issue summary to show where we are with this issue.

brahmjeet789’s picture

StatusFileSize
new2.41 KB

append the .append(' ') for the core/misc/machine-name.js

lewisnyman’s picture

Status: Reviewed & tested by the community » Needs review

Setting back to needs review then.

droplet’s picture

what is #32 trying to do ? uploaded a wrong patch ?

zaporylie’s picture

Status: Needs review » Reviewed & tested by the community

I looks like mixed patch for this issue with some other, unrelated piece of code.

#3 is still the one which should be committed.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Can some one upload the patch in #3 again so the correct path is the most recent patch on the issue.

nod_’s picture

Status: Needs work » Needs review
StatusFileSize
new1.63 KB

Reup of #3 with one small change:

Before

$suffix.append('<span class="machine-name-label">' + options.label + ':</span> ');

After

$suffix.append('<span class="machine-name-label">' + options.label + ': </span>');

Notice the space at the end is inside the span, which means that append will only add one DOM element, not two — a span and text element.

zaporylie’s picture

Status: Needs review » Reviewed & tested by the community

I have no problem to apply patch #37 and it works as designed and looks great on most recent version of D8. I believe it's time to close this issue and commit last patch.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

CSS and JS changes are not subject to beta evaluation and this change is not disruptive. Committed 58a891f and pushed to 8.0.x. Thanks!

  • alexpott committed 58a891f on 8.0.x
    Issue #2360175 by zaporylie, gaurav.goyal, droplet, sivaji@knackforge....

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

brahmjeet789’s picture