Steps to reproduce the bug:

  1. Install Drupal 7.15 with Minimal installation profile
  2. Assure the following modules are enabled:
    "Field", "Field SQL storage", "Field UI", "Filter", "Path", "PHP filter", "Text" (minimum enviroment for content types creation)
  3. Add a content type called Article, with all default options
  4. Try to create an article to see that "Body" field is normal
  5. Install Fieldgroup 7.x-1.1 (plus "CTools")
  6. Go to "Manage Fields" (Structure » Content types » Article »)
  7. Add a new group with a Fieldset widget and change "Fieldgroup settings" to collapsed
  8. Place "Body" field inside this fieldset
  9. Try to create an article, again, to see the "Body" field is still normal
  10. Now enable Wysiwyg 7.x-2.1 and install NicEdit 0.9 editor
  11. And then associate NicEdit with "Plain Text" input format
  12. At last try to create an article one more time to witness that "Body" field has shrunk

P.S.: With CKEditor 3.6.3.7474 there is no such problem.

Comments

3magnus’s picture

Component: User interface » Editor - nicEdit
TwoD’s picture

This happens because of a line in nicedit.js (inside NicEdit itself).
var panelElm = new bkElement('DIV').setStyle({width : (parseInt(e.getStyle('width')) || e.clientWidth)+'px'}).appendBefore(e);
e is a reference to the textarea being replaced by the editor.

The problem is that e.getStyle('width') will return 100% when the textfield is hidden (as that's how it's styled), which is then turned into the integer 100. The textarea doesn't actually have a calculated width yet. Even if NicEdit wasn't tricked into thinking 100% is 100px, it would probably not be able to figure out what 100% means until the textarea is shown and gets a calculated width anyway.

I'm not sure what to do about this since I can't find a reliable way to figure out how big the textarea is going to be either.

If you click "Disable rich-text" after opening the collapsed fieldset and then click "Enable rich-text", NicEdit will be able to figure out the correct size this time around as the textarea is now visible.

3magnus’s picture

Got the problem. It's tricky (without a better word to describe it).

My solution (for now) is exactly to enable the "rich-text" link, wich was not needed and was disabled at first.

And about the issue itself, I'm really not good at script languages (for now), but I can see two options to solve it:

  • discover how CKEditor can make it, since it doesn't shrinks at the same conditions
  • or alter the fieldset link, transfeering the "Enable rich-text" function to it, together with the "Open collapsible" function

I'll try to help more, but first I'll need some hard studying.

TwoD’s picture

CKEditor uses a different method to determine its initial size, as this happens internally in the editor I don't think we can do much about it.

I'm not sure I understand your second point.

3magnus’s picture

My workaround was: disable rich-text mode by default and enable rich-text toggle link. So when you just open the fieldset, the body field is in it's full size but configured for plain text only. Then you click in "enable rich-text" and everything goes normal.

And my point was about gathering theese two actions in just one link. So instead user clicking the fieldset title link (to open it) AND THEN clicking the enable rich-text link (to have it all), he/she could have both actions in just one clicking, on the fieldset opening link.

Of course this would only work if rich-text is disabled by default.

TwoD’s picture

Issue summary: View changes
Priority: Major » Normal
Related issues: +#1118906: WYSIWYG resized wrong when in hidden vertical tab

This is very similar to what happens with some editors in hidden vertical tabs.
I'll mark this a duplicate of that issue for now and I'll look into trying to detect whether an editor will be visible or not later. I'm not going to give it a very high priority though since the editor does still work and I don't think I can create a very reliable solution at this point.
I did implement something similar for the Summary fields, but doing the same for the main fields without altering the API behavior will be more difficult.

Any help would be appreaciated.

TwoD’s picture

Status: Active » Closed (duplicate)

*facepalm*
Actually marking it a duplicate...