In #925350: Vertical tabs broken, the following markup was added to solve the issues therein:
/**
* Prevent text inputs from overflowing when container is too narrow. "width" is
* applied to override hardcoded cols or size attributes and used in conjunction
* with "box-sizing" to prevent box model issues from occurring in most browsers.
*/
.vertical-tabs .form-type-textfield input {
width: 100%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
Doing so makes setting the #size FAPI key pointless, even if that's what a module author wants. In addition, it makes #field_prefix and #field_suffix pointless, as it results in the display problems exhibited in the attached picture.
This is a pretty big Drupal WTF and a FAPI regression. If one sets specific FAPI keys, Drupal core should honor them, not override them with CSS.
Comments
Comment #1
jacineI assume you realize why that was committed. Obviously, we didn't mean to break prefixes and suffixes, and will fix it. However, having fields extend beyond the container in almost every theme, in all browsers is just as big a WTF as far as I'm concerned.
I ran into a similar issue with yesterday, and came up with a better fix that should solve this problem for most browsers, but the ridiculous default size of 60 on the following fields is the source of the real problem here:
60 is just too big for most situations (especially mobile and vertical tabs) and forces this kind of CSS to be written. IMO this should be fixed at the source so we don't need to provide CSS to fix a broken set of defaults and we can all be happy.
Comment #2
mark trapp@Jacine: I do understand why it was committed; I didn't reopen the other issue or suggest a patch that reverts the change because of that.
I agree with you that changing the default size is probably the better way to solve the problem: forcing the width to be 100% is not ideal. My test case was for a field that had a
#sizeof 3: 100% width is pretty silly.Can you explain what your fix was, if not to change the default size for input fields? Right now, the only way I can see how a module author can deal with the change is to include their own CSS that overrides the
widthattribute for the fields they define.Comment #3
jacineI ran into an issue doing a mobile theme w/password fields (not in vertical tabs, but same deal). I fixed it by removing width: 100% and using max-width: 100%.
I haven't fully tested, since it was just last night that I ran into it, but I'm pretty sure it will solve the problem perfectly in IE7+. I need to do a little more testing on it (I'd like to setup a test for #suffix/#prefix and a few other combos) just to make sure.
We still would need to deal with IE6 though... It might be worth adding a container class to theme_form_element() to deal with it if the FAPI size change wont be allowed?
Comment #4
jacineErr, sorry I'm tired... That didn't make much sense. LOL. Let me try that again.
I ran into the problem having to special case password fields after applying the code in the original post to textfield and textareas. I applied it to all the fields because the problem actually exists on all of the fields (and bad) for mobile. The password fields couldn't be 100% because of the checker, so I fixed it as I noted above (max-width: 100%), and since it worked so well I replaced the original code with it and everything looks a gazillion times better with limited testing so far.
Comment #5
mark trappJust tested
max-width: the problem goes away even with#field_prefixand#field_suffix(see attached image).I think we can get away with using the star hack for IE6: we already use it immediately below the offending CSS, so it shouldn't be too much of an issue. Attached is a patch that incorporates your solution with the IE6-specific solution. While it'd be nice if core didn't muck around with a field's CSS, using
max-widthdoes fix the regression, and is far less invasive than changing the default size for all input elements.Comment #6
mark trappThis patch fixes the comments, which references
widthinstead ofmax-width.Comment #7
jacineGreat, I'm glad it works. Thanks for testing it and rolling the patch.
There are a couple of minor coding style issues:
Trailing white space.
The word "in" extends past 80 columns.
Powered by Dreditor.
I would like to fix the suffix/prefix issue out of the box in IE6. I think it would be a shame to make every theme that needs to support IE6 "deal" with this. I still think the FAPI default size of these elements should change, but yeah, the probability of that actually happening is really low at this point. I'll see if I can come up with anything that isn't too invasive in the meantime.
Comment #8
mark trappOops: shows me not to write a patch in the middle of the night. Attached patch fixes the code style issues. You're right: it doesn't fix the regression for IE6.
Comment #9
jacineUgh, well I did some more thorough testing, and this reverts fixes made in the previous patch. Apparently box-sizing needs an explicit width, and min/max-width alone don't work with it.
The only other thing I can think of to do (EDIT: with CSS), short of getting the default size changed is the following crazy hack that obviously will not fix all circumstances (i.e, when someone sets the size to something other than 60, that is too big for the container):
Screenshots of what I saw are attached.
Comment #10
jacineAlso, I can't figure out a good way to handle this in IE6. I was thinking we could add a class to the form element container based on:
Aside from the really ridiculous CSS that would mean adding, the problem is what do we set the CSS width to? Bartik breaks with two sidebars on size 27, Garland 36, etc. I guess we could tweak width of the tabs, to make Bartik work at 30, but the point is that it would still be a guess at the end of the day because we have no idea wide the suffix and prefix will be.
Specifically targeting the size=60 with CSS right now, and leaving IE6 broken is probably the best thing I can think of. It's not perfect, but it fixes both issues in IE7+, and overall it's not a very common occurrence that developers mess with size, other than to make an input smaller, from my experience.
I'm curious what you think about that or if you have any other ideas.
Comment #11
mark trappThe problem with setting the CSS to target input elements with size=60 is that the range of "broken" sizes is huge: from your testing, sizes 28 to 59 are also broken.
After thinking about it, the default size really shouldn't be changed either this late in the game. It might not be technically an API change, but its effect on module authors would be the same. If the difference was between 50 and 60 it's probably not a big deal, but we're talking cutting textfields by more than half their current width.
My thought now is that the change needs to be reverted: core should not be overriding FAPI keys just so it can fix its own FAPI elements. Instead, core should be doing one of two things:
I'm marking this major, because solving this problem is going to be non-trivial, and it can't stay in its current state.
Comment #12
mark trappActually, I think this might be critical, based on webchick's write-up:
Someone can always downgrade it if I misunderstood the guidelines.
Comment #13
chx commentedWhile I truly appreciate the work on this issue it's nowhere near critical. Vertical tabs did not even exist in Drupal 6 therefore it can not be a regression. Also, how would be so many users affected that we can't release? Compare this to data loss bugs, WSOD etc. You can always override a CSS if it really does not work for you.
Comment #14
chx commentedUpon discussing the issue, it's major.
Here's the problem: Form API lets you define a
#sizewhich sets the visible size of an input element. However, setting width in CSS also does the same and has priority. Also, by taking all space possible,#field_prefixand#field_suffixno longer have the space to be on the left and right of the input element.Agreed it looks a serious problem but -- only inside a vertical tab.
Comment #15
jacineThis is definitely not critical, but I agree that it's major.
Shipping with broken vertical tabs in all browsers for every theme that decides to use 2 sidebars is not an option. I'm sorry, but no. Hard coding pixel widths is not an option either. To impose this on all themes because the correct solution is too hard, or simply an API change late in the game for module developers is not something I am willing to sit here and watch.
If we really care about fixing this, then let's fix what's actually broken, instead of dumping it and blaming it on the theme layer. As mentioned in #1 the default size of 60, applied to certain field types is the problem. If we are willing to fix that great.
If not, I do not support reverting the previous patch.
Comment #16
mark trappAfter discussing this, I'm on board with changing the default size: attached is a patch that changes it to 30 and reverts the CSS in question (since it's no longer needed).
Jacine mentioned that there are still theme implications to Bartik, which I can confirm but I am not versed enough in the theme to solve. The patch attached would at least fix the regression, and we can solve the Bartik issues afterward.
Comment #17
mark trappAlso, assuming this is committed, we'll need to change the Forms API reference documentation to reference the new default value for
#size.Comment #18
jacineGreat!
This does solve the CSS problems, which is awesome. Some fields, like node titles look a little odd though. I think it would make sense to set those fields to 60 where it makes sense.
I'm gonna take inventory of these and report back soon.
Comment #19
jensimmons commentedsubscribe.
If this patch affect Bartik, be sure to fix whatever gets borked, please.
Comment #20
webchickYeah, sorry. There's no way we can change the system defaults. Those have been in place since Drupal 4.7, literally since just after the FAPI was invented, and changing those would have tremendous effect on both module and theme developers.
But one-offing a #size on an affected field being displayed in vertical tabs seems fine.
Comment #21
webchickComment #22
mark trapp@webchick fair enough. Just so I understand your suggestion: if we set
#sizeto 30 on all FAPI elements that core defines that appear in vertical tabs, that'd be okay? This would leave the default value the way it is, revert the offending CSS, and require module authors to be aware enough that if they define a FAPI element that's going to be in a vertical tab, they need to set the#sizekey to something sane.Comment #23
jacineThat works for me. I think the defaults are something worth addressing, but 8.x seems more appropriate given that lots of fields use the 60 default, and the change would be pretty invasive to say the least.
Would it be a crazy to automatically adjust the size to a 30 max in template_preprocess_vertical_tabs() or a pre-render function?
Comment #24
mark trappI like the pre-render function idea, but I couldn't find a way to determine if an element exists within a group using it. However, using a process function works since they are passed
$form_state.Attached is a patch that does the following:
form_process_size(), that determines if an element is a member of a renderable group and if the element has an unsafe#size. If so, it readjusts the value of#sizeto 30; andtextfield,password,password_confirm,file, andtextareaform elements.form_process_size()also handles#cols, but resizable textarea elements are forced to 100% width in system/system.base.css:Removing that CSS breaks the grippie, and I'm pretty sure that's how it worked in Drupal 6, so I don't consider it to be a regression.
Comment #26
mark trappOops, wasn't paying attention and added
form_process_sizeto#theme_wrappersinstead of#processfor thefileelement.Comment #27
jacineThis code, slightly changed, is still needed:
Other than that, the patch is okay for all of the other themes are good, except Bartik and I've been having a hell of a time trying to make it behave because:
topandborder-radiusbeing applied to the fieldsets which is being inherited..fieldset-wrapperin addition to what vertical tabs is providing, which makes the already small horizontal space even smaller.word-wrap: break-word, which took forever to track down is actually breaking the layout in IE6.The attached patch adds to Mark's patch in #26 and does the following:
in vertical-tabs.css:
.fieldset-wrapperpadding to 0. It's pretty common to add padding to these and it's problematic inside vertical tabs, so vertical-tabs.css should try to prevent it.in bartik's style.css
word-wrapto normal fordiv.vertical_tabs.fieldsetstyles that should not be applied inside vertical tabs.PS - It's still not perfect because
selectlists break the layout in IE and still extend beyond the container in all modern browsers, but I'm out of ideas and that isn't directly related to this issue.Some screenshots are attached.
Comment #28
mark trappI haven't been able to test your changes yet, but after discussing the patch with merlinofchaos in IRC, the hardcoded 30 for the maximum safe value seems just as bad as changing all the default values of form elements core defines. What if I really, really want a #size 45 element to keep the attribute size set to 45? There should be some way to override that beyond using CSS.
So I've modified your patch to replace the hardcoded number with a variable,
vertical_tabs_max_field_size, that defaults to 30. This way, there's some way to override that value without having to hack core.I should be able to test the rest of the changes in the next day or so.
Comment #29
mark trappMinor change: we don't need to look up the max field size unless the field will be part of a renderable group.
Comment #31
mark trappLet's try that again.
Comment #32
mark trappTypo.
Comment #33
mark trappI was able to test the CSS changes made in #27 (and carried through to #32), and they work as advertised in Safari for Desktop 3.1.2+, Safari for iPhone OS 3, Safari for iOS 4, Firefox 1.5+, Opera 9.27+, and Internet Explorer 6+.
Not marking the whole patch as RTBC due to the change proposed in #28, but the rest of the patch is.
Comment #34
jacineI like the idea of a variable for this, just so it's not so terribly hard coded.
I'm not comfortable setting it to RTBC. I mean, it looks good to me, but I don't have awesome PHP chops, so it would be great if a developer could review.
Comment #35
mark trapp#32: drupal-970426-32-fix-fapi-regression-11.patch queued for re-testing.
Comment #37
mark trapp#32: drupal-970426-32-fix-fapi-regression-11.patch queued for re-testing.
Comment #38
mark trapp#32: drupal-970426-32-fix-fapi-regression-11.patch queued for re-testing.
Comment #39
mark trappAny comments on this? Its my understanding this needs to get in before RC1 if it's going to be fixed, and that's today.
Edit: nevermind, this can wait until after RC1.
Comment #40
dixon_Although I'm not sure if this can make it into D7 (because of the late FAPI changes), the Drupal 7 release party in Gothenburg, Sweden will test and review this patch so we hopefully can make some progress on it.
I'm by no way stealing the issue by assigning it to me, just stating that I will coordinate some work on this later today.
Comment #41
dixon_No need for me to "hold" on to this issue. Party is over now :)
Comment #42
longwaveBumping this to D8 and subscribing.
Comment #43
longwave#32: drupal-970426-32-fix-fapi-regression-11.patch queued for re-testing.
Comment #45
sunThe patch doesn't look acceptable to me. Highly interested in alternative implementation ideas. Ideally backportable to D7.
Comment #46
mark trappComment #47
doitDave commentedI successfully tested
width: 100%; max-width: 100%; width: auto;which is IIRC known as an IE-safe legacy workaround.As a workaround, I apply this in the '#attributes' FAPI property of my custom form elements.
Comment #60
quietone commentedThere has been no discussion here since 2015, and work on the patch ended in 2011. The block of code in the Issue Summary was removed from core on Wed May 1 18:43:20 2013 in #1978036: Clean up css in vertical tabs. Based on that I am closing this issue as outdated.