Problem/Motivation
All forms Labels text contain a trailing SPACE.
- when adding background color to the element, there is no way to remove the space.
- non-relevant SPACE inside html tag is not a best practice.
- Simpletest & JS lookup to labels. It's odd. (eg. #1623564: Wrong text at translation UI)
Proposed resolution
- Removing labels text's trailing SPACE
- Removing the SPACE before Labels
workarounds for people who cannot use the patch / after committed:
- using CSS to adding space between 2 form elements.
eg.
.form-item .option:before {
content: " ";
}
Remaining tasks
- Decide if we want to keep spaces between checkboxes and radio button and their labels, and the space inside the label of a required field. See comment #30
User interface changes
Core: No visual Changes
Custom themes: (if users adding background & padding-left to fix space problem. Now, it might lose one space at right side.)
(seldom happens)
Custom modules: module authors have to update their simpletest.
API changes
-
Updated to comment #30
Comment | File | Size | Author |
---|---|---|---|
#87 | interdiff-1623574-83-87.txt | 655 bytes | zaporylie |
#87 | remove_trailing_space-1623574-87.patch | 2.67 KB | zaporylie |
#83 | remove_trailing_space-1623574-83.patch | 2.65 KB | cilefen |
#81 | with-margin.png | 235.02 KB | mbroere |
#81 | without-margin.png | 243.22 KB | mbroere |
Comments
Comment #1
tlattimore CreditAttribution: tlattimore commentedTagging as needs review to the cue bot.
Comment #3
joachim CreditAttribution: joachim commentedRelated: #991522: Vertical tabs summaries have stray spaces. This fix would possibly fix the problem over there.
Comment #4
droplet CreditAttribution: droplet commentedThanks for the ref @joachim :)
I'm also removed JS $.trim at following patch -> If users really need a SPACE, we should not remove it.
Comment #5
tlattimore CreditAttribution: tlattimore commentedPatch in #4 looks good, applies cleanly, and conforms to coding standards.
Comment #6
andypostAny reasont to leave this prefix before label?
same
same
Comment #7
droplet CreditAttribution: droplet commented#1 example:
#2 & #3 add space between word the hide link:
Summary (Hide summary)
Comment #8
andypost#1 adds a useless space befor label
id="edit-menu-enabled"> <label
I think #2 & #3 probably makes sense
Comment #9
droplet CreditAttribution: droplet commentedSince this is not inject spacing inside the tag, we able to style it with CSS. By remove the SPACE in this code, I afraid it will break a lot of themes.
Let wait for one more reviewer?
(EDIT: rephrase my word to more clearly)
Comment #10
tedstein CreditAttribution: tedstein commentedI think this patch is important. A lot of themes, and automated tests, will rely on the space if it is not removed. The space is, as droplet said, a CSS issue. The space is a bug, and needs fixing.
Comment #11
tim.plunkettMarking as a duplicate of #991522: Vertical tabs summaries have stray spaces, you can widen the scope of that issue but it does pretty much the same thing and is 1.5 years older.
Same thing happened to me #1542700: Content type fieldset summaries contain extra spaces a couple months ago :)
Comment #12
joachim CreditAttribution: joachim commentedThis issue may be newer but it has the wider scope already and it has the patch for that, so I reckon this is the one we should keep open :)
Comment #13
droplet CreditAttribution: droplet commentedReroll.
No way to generate a good interdiff, here is the main changes:
Comment #14
droplet CreditAttribution: droplet commentedInteresting, thats 2 spaces between radio/checkbox & form label. Also removed #9 space. will it break the bot ? Let's go.
Comment #14.0
droplet CreditAttribution: droplet commentedfix
Comment #14.1
droplet CreditAttribution: droplet commentedIS
Comment #14.2
droplet CreditAttribution: droplet commentedUpdated issue summary.
Comment #15
stevecowie CreditAttribution: stevecowie commentedPatch at #14 no longer works - line references wrong - i'll reroll.
Comment #16
stevecowie CreditAttribution: stevecowie commentedre-roll of #14 ready for test
Comment #17
droplet CreditAttribution: droplet commented#16: remove-trailing-space-1623574-15.patch queued for re-testing.
Comment #19
droplet CreditAttribution: droplet commentedtagging Novice, anyone willing to reroll a patch, thanks.
Comment #20
patrickfgoddard CreditAttribution: patrickfgoddard commentedRe-rolled. However, due to this issue: http://drupal.org/node/1685140, the changes done to collapse.js in previous patches no longer is relevant (that whole chunk removed.
I'm not sure I'm doing this correctly, so feel free to look over and review. (followed instructions from http://drupal.org/patch/reroll to reroll)
Comment #21
patrickfgoddard CreditAttribution: patrickfgoddard commentedUpdating status.
Comment #23
patrickfgoddard CreditAttribution: patrickfgoddard commentedSo the test failed at: "Detect a Drupal installation failure"
Details:
10:13:17] Invoking operation [install]...
[10:13:18] Encountered error on [install], details:
array (
'@reason' => 'Installing: failed to arrive at database configuration page using install path http://drupaltestbot664-mysql/checkout/install.php?profile=standard&langcode=en',
)
[10:13:18] Review complete. test_id=335523 result code=7 details=Array
(
[@reason] => Installing: failed to arrive at database configuration page using install path http://drupaltestbot664-mysql/checkout/install.php?profile=standard&langcode=en
)
Is that because of the patch, or is something else going on?
Comment #24
patrickfgoddard CreditAttribution: patrickfgoddard commentedRemoving "old mode", "new mode" lines. Don't think that's necessary and hoping that is what was causing the tests to fail.
Comment #26
patrickfgoddard CreditAttribution: patrickfgoddard commentedThird times a charm?
Discovered drupal_attributes call is now replaced by Attribute object. Modified patch and am resubmitting.
Comment #27
patrickfgoddard CreditAttribution: patrickfgoddard commentedChanging status.
Comment #28
acmaintainer CreditAttribution: acmaintainer commentedI am a novice and found this issue via the novice tag. This is the first core issue I have participated in.
I applied the patch cleanly.
The patch did remove trailing spaces from all labels with the exception of the ones in the login block. There is space between the label text and the "abbr" tag and I am not sure if it should be there.
Comment #29
MarkoV CreditAttribution: MarkoV commentedloose_space.patch queued for re-testing.
Comment #30
Evan King CreditAttribution: Evan King commentedReproduced the issue
Patch 26 applied cleanly and does remove the trailing space inside tags.
Comment #28 noted that spaces still appear in labels of required fields, but this is to separate the text of the label from the asterisk which indicates it is a required field. I'm not sure if this is desired behaviour or not.
However, the leading space before tags still exists after a checkbox or radio button.
Again, I'm not sure if this is desired behaviour or not.
In both of these cases, I'd vote to keep those spaces in, otherwise we'll lose the visual separation unless a theme knows to style for it. But maybe that's what we want?
Comment #30.0
Evan King CreditAttribution: Evan King commentedUpdated issue summary.
Comment #31
barraponto CreditAttribution: barraponto commentedPatch looks ok to me.
Regarding the "required" space, I'd suggest a CSS solution. But not the ugly
margin-left: 2px
workaround, but rather a.form-required:before { content: " "; }
However, right now, the space is added in a t() call — although I have no idea why the required marker is being passed to the t() function. Another issue, maybe?Anyway, I'll add the CSS generated content workaround to the issue summary. It's safe for every browser and IE>8, see http://caniuse.com/#feat=css-gencontent
Comment #31.0
barraponto CreditAttribution: barraponto commentedPatch #26 works fine, but we need to decide if we want to keep spaces between checkboxes and labels, and between label text and the asterisk indicating a required field. suegegambit
Comment #32
droplet CreditAttribution: droplet commented#26: remove-trailing-space-1623574-26.patch queued for re-testing.
Comment #34
sunThis cannot be backported to D7, as it would potentially break hundreds of thousands of themes. ;)
However, we absolutely need to get rid of this.
There's one more incarnation of this, which is even worse: theme_field() outputs an explicit
. Can't get any more ugly. ;) Let's also fix that instance right here, right now.In general, this patch should remove the offending white-space everywhere, instead of moving it around. If necessary, the CSS should inject an appropriate margin (or padding).
Both of these should be exclusively handled by CSS.
@stevecowie, any chance to get back to this?
Comment #35
sunSo... erm... the majority of this issue/patch actually happened as part of the patch in #1838114: Change node form’s vertical tabs into details elements already... (I *knew* I touched those very lines already...)
Re-rolling the last patch against HEAD, and incorporating
theme_field()
leaves us with the attached patch only.Let's see how it goes.
Comment #37
tstoeckler#35: drupal8.label-whitespace.35.patch queued for re-testing.
Edit: Failed Git checkout.
Comment #38
droplet CreditAttribution: droplet commentedNice, I hope we could add back a SPACE to:
Body(Edit summary)
=>
Body (Edit summary)
Comment #39
sunYes, we can. But not with a space. CSS is the key. :)
Comment #40
droplet CreditAttribution: droplet commentedLooks good to me :)
Comment #41
shnark CreditAttribution: shnark commentedI don't understand what this change is doing, I read the comments, and didn't see this mentioned.
this part makes sense, they removed the space, and added a margin in CSS.
The coding standards look fine.
Comment #42
droplet CreditAttribution: droplet commentedLooking back to D7 (before #1838114: Change node form’s vertical tabs into details elements), form API will add SPACE to label (some form elements). Therefore, blockSettingsSummary generated summary with SPACE, we add $.trim to remove the SPACE.
Also @see: http://drupal.org/node/1623574#comment-6097740
Comment #43
sunThe change to
theme_field()
requires manual testing + before/after screenshots for confirmation.With those, this patch should be RTBC. Any takers? :)
Comment #44
sun#39: drupal8.label-whitespace.39.patch queued for re-testing.
Comment #45
sunCan anyone do a quick visual review to confirm the changes of this patch? :)
Comment #46
sunAlright, one before vs. after screenshot for the removal of whitespace and colon from field labels:
And one additional screenshot for the .field-edit-link margin tweak, affecting the "(Edit summary)" link:
With these, we should be RTBC here.
Comment #47
YesCT CreditAttribution: YesCT commented#39: drupal8.label-whitespace.39.patch queued for re-testing.
Comment #48
YesCT CreditAttribution: YesCT commentedif the testbot says green, rtbc from me.
the code was already looked at in #40 and #41, and I looked at it, again, looking good.
The manual testing and screenshots are in #46
Comment #49
Dries CreditAttribution: Dries commentedWe all like pretty HTML. :-) Committed to 8.x. Thanks.
Comment #50
yched CreditAttribution: yched commentedSeveral issues with the Field part of this :
.field-edit-*link* ? what does this match ?
- The patch removes a
: 
from theme_link() (used for *displayed* entities), and replaces (?) it with some margin on forms ?- That
: 
(the column and the space) was there when the field display is configured with label "inlined". That case is now broken - see screenshot below for field "Some text" :- If it gets removed from theme_field(), it also needs to be removed from field.tpl.php
Comment #51
yched CreditAttribution: yched commented(also, note from the screenshot that bartik's bartik_field__taxonomy_term_reference() still prints the column for taxonomy field labels)
Comment #52
sunThe quoted CSS is for the "Edit summary" link of text_summary field widgets in a form. (see #46)
Thanks, looks like we overlooked inline field labels :) For these, we should add a class and corresponding CSS rule along the lines of this:
Comment #52.0
sunUpdated issue summary.
Comment #53
LewisNymanComment #54
cesarmiquel CreditAttribution: cesarmiquel commentedI'm working on a patch and screenshots. We're handling this issue in Drupal Con Austin in the front end/twig sprint. Will submit shortly.
Comment #55
cesarmiquel CreditAttribution: cesarmiquel commentedSubmitting a patch for this which removes the and replaces it with CSS. Tested in Stark and Bartik with LTR and RTL languages. I'm attaching some screenshots:
Bartik before patch:
Bartik after patch:
Stark before patch:
Stark after patch:
Comment #57
cesarmiquel CreditAttribution: cesarmiquel commentedFixed the test as well and re-submitting my previous patch. I also uploaded an interdiff for easier review.
Comment #59
joelpittetYou'd need to remove the ':' as well because that is no longer part of the markup.
This is not equivilent to a but considering it's in a div, that's probably fine but just wanted to point that out.
Comment #60
cesarmiquel CreditAttribution: cesarmiquel commentedThanks Joel! I delayed to re-submit the patch because I was trying to reproduce the fail on my local environment and couldn't. So I'm resubmitting the patch with the same correction you are suggesting. I'm also submitting the interdiff.txt. Lets cross our fingers :-).
Comment #61
joelpittetyw @cesarmiquel and thanks for working on this!
@sun you can do the honors?
RTBC++
Comment #62
star-szrLooks good to me, just want to note for the commit message that @zetagraph worked on this at the sprint also and should get a commit mention.
Could be better but something like:
Comment #63
cesarmiquel CreditAttribution: cesarmiquel commentedAs Scott said, Andrei (a.k.a. @zetagraph) also contributed significantly to getting this done. Glad to have helped and hoping to contribute more on other issues :-).
Comment #64
droplet CreditAttribution: droplet commentedwow. I'm surprised a lot of issues in this thread has been committed in other issues but no one linking back. I found some new problems.
Will this issue get committed at final ?
- changed to margin-right. removed background color issues. see issue summary
- removed space in .field-label-inline .field-label::after
If we wanna add space in CSS content should be:
Comment #65
droplet CreditAttribution: droplet commentedAlso, edit summary, no more space
Comment #66
cilefen CreditAttribution: cilefen commentedI was able to reproduce the extant issues as I understand them in Stark in RTL and LTR on Chrome and Firefox 30.0 on OS X 10.9.3. They are:
The patch applied cleanly and fixed those issues.
But in Bartik there is an extra colon after the taxonomy label.
This patch removes the extra colon.
Comment #67
valthebaldAfter applying patch from #66 there is no colon at all:
Before patch:
After patch:
Comment #68
cilefen CreditAttribution: cilefen commentedIn Bartik and Stark:
#65 produces two colons after the taxonomy label when the label is inline and one when the label is above.
#66 produces one colon after the taxonomy label when the label is inline and none when the label is above.
Comment #69
valthebald@cilefen: why to remove colon when label is above?
Comment #70
cilefen CreditAttribution: cilefen commented@valthebald True. Is it as simple as this?
Comment #71
cilefen CreditAttribution: cilefen commentedComment #73
er.pushpinderrana CreditAttribution: er.pushpinderrana commented#70 looks fine, should moved to Need Review status. As
interdiff-66-70.patch
filename was wrong, it should beinterdiff-66-70.txt
. Rename and uploadedinterdiff-66-70.txt
file and moved this toNeed Review
status.Comment #74
sunWhy does the latest patch add a colon to all field labels now?
Only inline field labels should be adjusted, as in the previous patches up till #66.
Comment #75
prashantgoel CreditAttribution: prashantgoel commentedComment #76
mbroere CreditAttribution: mbroere commentedRe-roll of 66
Inline
Above
Comment #77
mbroere CreditAttribution: mbroere commentedComment #79
joelpittetThanks for re-rolling this patch! It looks good just one question:
Was this accounted for? Could you take a screenshot of this? It was taken in #46 for the summary field I believe.
Comment #81
mbroere CreditAttribution: mbroere commentedThe margin on .field-edit-link was removed in patch-65 and looks alright:
Without margin:
With margin:
Comment #82
LewisNymanLooks good to me. Unfortunately this needs a reroll.
Comment #83
cilefen CreditAttribution: cilefen commentedreroll
Comment #84
valthebaldScreenshots clearly show the difference, thanks @mbroere
Patch looks good as well
Comment #85
alexpottShould have
/*LTR*/
comment onmargin-right
too.don't you mean
margin-left
and don't we have to resetmargin-right
here?EDIT: Improved code context
Comment #86
zaporylieComment #87
zaporylie@alexpott has absolutely right. I've attached improved patch, interdiff and some screens how it looks now.
LTR without margin:
LTR with margin:
RTL without margin reset:
RTL with margin reset:
Comment #88
joelpittetAwesome, thanks for the screenshots. This looks like it should do the trick and addresses #85
Comment #89
alexpottCommitted f04c960 and pushed to 8.0.x. Thanks!