Quickest way to see the problem is to look at the attached images of the admin/people/permissions page in the current 7.x-dev. You will see that the disabled checkboxes show up in the wrong place. This is because they have style="display:block;" instead of "display:inline;"

The admin/people/permissions page displays properly in 7.0-alpha2. The change that triggered the problem was the move from jQuery 1.3.2 (Drupal CVS rev 1.17), which was used in 7.0-alpha2, to jQuery 1.4.2 (Drupal CVS rev 1.18), which is used now in 7.x-dev.

The checkboxes are created by the jQuery code in user.permissions.js, and the fix is to swap two lines of code.

Before the fix:

$('<input type="checkbox" class="dummy-checkbox" disabled="disabled" checked="checked" />')
  .attr('title', Drupal.t("This permission is inherited from the authenticated user role."))
  .hide()
  .insertAfter(this);

After the fix:

$('<input type="checkbox" class="dummy-checkbox" disabled="disabled" checked="checked" />')
  .attr('title', Drupal.t("This permission is inherited from the authenticated user role."))
  .insertAfter(this)
  .hide();

The reason for doing this is, if you hide() a newly created element before adding it to the DOM (as in the "before" code), when you go to show() it, show() will set an explicit style="display: block;" on that element, regardless of what is in the CSS or what that element normally defaults to. This is a documented feature of jQuery going back to at least jQuery 1.2.

If however you add the newly created element to the DOM first, then hide() it (as in the "after" code), show() will remember the initial display settings. In the case of the disabled checkboxes, these initial settings will default to "display:inline;", like the rest of the checkboxes on the page.

If you want to confirm that the jQuery version triggers the bug, you can revert jquery.js to CVS rev 1.17 and see the problem go away. However the real fix is not to back off on jQuery, but to rewrite the Drupal .js to avoid this behavior.

Patch follows ...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

TR’s picture

Status: Active » Needs review
FileSize
856 bytes

Patch attached.

TR’s picture

Images got lost from the initial post ...

TR’s picture

#1: 752508-user-permissions-js.patch queued for re-testing.

Georg’s picture

I was able to produce this bug only in Firefox. IE, Safari, Chrome and Opera don't not have this misbehavior.

After applying the patch, all Browsers display this correctly.

webchick’s picture

Status: Needs review » Fixed

Whew! Thanks for saving my bacon just before my big D7 demo at Drupalcon! :D Committed to HEAD.

Status: Fixed » Closed (fixed)

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