If you have a right sidebar and do a comment preview the layout breaks. Sidebar right jump out of position becouse of a missing

CommentFileSizeAuthor
#4 empty_markup_value.patch695 byteskndr

Comments

sun’s picture

Status: Active » Postponed (maintainer needs more info)

Some information got lost here. Please use <code> tags to post HTML code.

detot’s picture

just wrote </div>, seems to be loosing a end div on the comment preview pages

sun’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

That sounds like a self-made problem in your theme.

I have no issues with comment previews.

kndr’s picture

Status: Closed (won't fix) » Needs review
StatusFileSize
new695 bytes

I confirm this issue. My layout is broken during comment preview and indeed there is no </div> tag. I've spent many hours to find the reason since I suspected that comment.module or my custom functions was the source of problem. By chance I stumbled upon this issue and after short testing I was sure, that style button module should be patched. When comment is previewed, markup 'comment_preview_below' is the last children of $form. 'comment_preview_below' is set inside function comment_form_add_preview() in comment.module. There is the condition statement:

  $output = '';

  if ($edit['pid']) {
    $comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.signature_format, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = %d', $edit['pid'], COMMENT_PUBLISHED));
    $comment = drupal_unpack($comment);
    $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
    $output .= theme('comment_view', $comment, $node);
  }
  else {
    $suffix = empty($form['#suffix']) ? '' : $form['#suffix'];
    $form['#suffix'] = $suffix . node_view($node);
    $edit['pid'] = 0;
  }

  $form['comment_preview_below'] = array('#value' => $output, '#weight' => 100);

As you can see $output could be equal empty value and '#value' of 'comment_preview_below' could be empty too. Now, if we look into button_style.module at function button_style_form_after_build() we can see, that markup with empty value could be assign to $actions_end variable:

else if (isset($actions_start) && (
        (!isset($form[$item]['#type']) && !empty($form[$item]['#value']))
        || (isset($form[$item]['#type']) && $form[$item]['#type'] == 'markup' && !empty($form[$item]['#value']))
      )) {
        $actions_end = $item;
      }

At the end there is an assigment:

  $form[$actions_end]['#suffix'] = (isset($form[$actions_end]['#suffix']) ? $form[$actions_end]['#suffix'] : '') . '</div>';

I suspect, that FAPI doesn't render markup when its value is empty. This could be the reason of disappearing '</div>' tag and breaking the layout. I've attached the patch, where I check if markup value is empty.

detot’s picture

Status: Needs review » Reviewed & tested by the community

Solved my problem, Thanks

sun’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for reporting, reviewing, and testing! Committed to all branches.

A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.

Status: Fixed » Closed (fixed)

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