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

jacine’s picture

I 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:

  • file
  • password
  • password_confirm
  • textarea
  • textfield

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.

mark trapp’s picture

@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 #size of 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 width attribute for the fields they define.

jacine’s picture

I 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?

jacine’s picture

Err, 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.

mark trapp’s picture

Status: Active » Needs review
StatusFileSize
new13.91 KB
new826 bytes

Just tested max-width: the problem goes away even with #field_prefix and #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-width does fix the regression, and is far less invasive than changing the default size for all input elements.

mark trapp’s picture

StatusFileSize
new1.28 KB

This patch fixes the comments, which references width instead of max-width.

jacine’s picture

Status: Needs review » Needs work

Great, I'm glad it works. Thanks for testing it and rolling the patch.

There are a couple of minor coding style issues:

+++ misc/vertical-tabs.css	13 Nov 2010 07:49:11 -0000
@@ -62,16 +62,20 @@ div.vertical-tabs {
+ * Prevent text inputs from overflowing when container is too narrow. ¶

Trailing white space.

+++ misc/vertical-tabs.css	13 Nov 2010 07:49:11 -0000
@@ -62,16 +62,20 @@ div.vertical-tabs {
+ * in conjunction with "box-sizing" to prevent box model issues from occurring in

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.

mark trapp’s picture

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

Oops: 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.

jacine’s picture

Status: Needs review » Needs work
StatusFileSize
new36.74 KB
new27.55 KB

Ugh, 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):

.vertical-tabs .form-type-textfield input[size="60"] {
  width: 100%;
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

Screenshots of what I saw are attached.

jacine’s picture

Also, 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:

  1. whether a #field_suffix/prefix has been set.
  2. whether a #size greater than 30 has been set.

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.

mark trapp’s picture

Priority: Normal » Major

The 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:

  1. Specifying the width on elements it defines that appear in vertical tabs so that they fit, or
  2. Conditionally changing the default size to 27ish when form elements appear in vertical tabs.

I'm marking this major, because solving this problem is going to be non-trivial, and it can't stay in its current state.

mark trapp’s picture

Priority: Major » Critical

Actually, I think this might be critical, based on webchick's write-up:

A critical bug is something that breaks Drupal so horribly in a way that affects so many users that we can't possibly release without it being fixed. [...]

As a general rule, these include:

[...]
• Serious regressions from behaviour that worked in previous releases

Someone can always downgrade it if I misunderstood the guidelines.

chx’s picture

Priority: Critical » Normal

While 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.

chx’s picture

Priority: Normal » Major

Upon discussing the issue, it's major.

Here's the problem: Form API lets you define a #size which 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_prefix and #field_suffix no 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.

jacine’s picture

This 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.

mark trapp’s picture

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

After 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.

mark trapp’s picture

Also, assuming this is committed, we'll need to change the Forms API reference documentation to reference the new default value for #size.

jacine’s picture

Great!

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.

jensimmons’s picture

subscribe.

If this patch affect Bartik, be sure to fix whatever gets borked, please.

webchick’s picture

Yeah, 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.

webchick’s picture

Status: Needs review » Needs work
mark trapp’s picture

@webchick fair enough. Just so I understand your suggestion: if we set #size to 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 #size key to something sane.

jacine’s picture

That 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?

mark trapp’s picture

Status: Needs work » Needs review
StatusFileSize
new5.39 KB

I 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:

  • Reverts the CSS that caused the regression,
  • Adds a new process function, 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 #size to 30; and
  • Attaches the process function to textfield, password, password_confirm, file, and textarea form elements.

form_process_size() also handles #cols, but resizable textarea elements are forced to 100% width in system/system.base.css:

.form-textarea-wrapper textarea {
  display: block;
  margin: 0;
  width: 100%;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

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.

Status: Needs review » Needs work

The last submitted patch, drupal-970426-24-fix-fapi-regression-5.patch, failed testing.

mark trapp’s picture

Status: Needs work » Needs review
StatusFileSize
new5.34 KB

Oops, wasn't paying attention and added form_process_size to #theme_wrappers instead of #process for the file element.

jacine’s picture

StatusFileSize
new41.56 KB
new52.85 KB
new33.32 KB
new49.6 KB
new7.03 KB

This code, slightly changed, is still needed:

* html .vertical-tabs .form-type-textarea {
  width: 95%; /* IE6 */
}

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:

  • top and border-radius being applied to the fieldsets which is being inherited.
  • there's horizontal padding in .fieldset-wrapper in 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 font size is just too big in combination with the 15em width of the tab list and the 960px.

The attached patch adds to Mark's patch in #26 and does the following:

in vertical-tabs.css:

  • Makes the width of the tab list 13em instead of 15em. 15em is too wide with a 960px layout and two filled sidebars where it looks more like 50% tabs/50% content, and this is common. This change will not affect Seven because it uses a fixed width and doesn't have sidebar combinations to deal with, so I think it's fine.
  • Sets .fieldset-wrapper padding 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

  • Removing left/right padding applied to fieldset.vertical-tabs-panel.
  • Setting word-wrap to normal for div.vertical_tabs.
  • Resets thefieldset styles that should not be applied inside vertical tabs.

PS - It's still not perfect because select lists 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.

mark trapp’s picture

I 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.

mark trapp’s picture

Minor change: we don't need to look up the max field size unless the field will be part of a renderable group.

Status: Needs review » Needs work

The last submitted patch, drupal-970426-29-fix-fapi-regression-9.patch, failed testing.

mark trapp’s picture

Status: Needs work » Needs review
StatusFileSize
new7.12 KB

Let's try that again.

mark trapp’s picture

Typo.

mark trapp’s picture

I 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.

jacine’s picture

I 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.

mark trapp’s picture

Status: Needs review » Needs work

The last submitted patch, drupal-970426-32-fix-fapi-regression-11.patch, failed testing.

mark trapp’s picture

Status: Needs work » Needs review
mark trapp’s picture

mark trapp’s picture

Any 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.

dixon_’s picture

Assigned: Unassigned » 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.

dixon_’s picture

Assigned: dixon_ » Unassigned

No need for me to "hold" on to this issue. Party is over now :)

longwave’s picture

Version: 7.x-dev » 8.x-dev

Bumping this to D8 and subscribing.

longwave’s picture

Status: Needs review » Needs work

The last submitted patch, drupal-970426-32-fix-fapi-regression-11.patch, failed testing.

sun’s picture

Priority: Major » Normal
Issue tags: +Needs backport to D7

The patch doesn't look acceptable to me. Highly interested in alternative implementation ideas. Ideally backportable to D7.

mark trapp’s picture

doitDave’s picture

Issue summary: View changes

I 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.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Version: 9.5.x-dev » 11.x-dev
Status: Needs work » Closed (outdated)
Issue tags: +Bug Smash Initiative

There 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.