Closed Bug 1428838 Opened 8 years ago Closed 3 years ago

Click on link in disabled fieldset doesn't bubble click event up but does perform navigation default action

Categories

(Core :: DOM: UI Events & Focus Handling, enhancement, P3)

enhancement

Tracking

()

RESOLVED DUPLICATE of bug 1829874

People

(Reporter: bzbarsky, Unassigned)

References

Details

Testcase: <body onclick="alert('hello'); return false"> <fieldset disabled> <a href="http://example.com">Clicking this link should not navigate</a> </fieldset> </body> This is related to bug 1220048, but this is not a case of being inside a disabled form control like a button. The behavior here just looks broken to me.
Flags: needinfo?(bugs)
In particular, HTMLFieldSetElement::GetEventTargetParent does: aVisitor.mCanHandle = false; if (IsDisabledForEvents(aVisitor.mEvent->mMessage)) { return NS_OK; } which seems pretty odd to me for a fieldset...
To reinforce this, see my comment over here: https://bugzilla.mozilla.org/show_bug.cgi?id=218093#c48 It is based on a real life use case in a Rails app, appearing in both plain Javascript and JQuery.
Yeah, this is broken. The question is what the behavior should be.
I think the event firing should just work normally in this case. <fieldset disabled> doesn't disable the fieldset itself in any way. It just disables all the form controls inside the fieldset (and not even all of those, per spec; the ones inside the <legend> shouldn't get disabled, but we prevent event propagation out of the legend of a disabled fieldset too!). Clicking on those controls will do whatever we normally do for disabled controls. Clicking on other elements will behave normally. In practice, I propose removing HTMLFieldSetElement::GetEventTargetParent altogether and maybe making HTMLFieldSetElement::IsDisabledForEvents return false unconditionally.
Priority: -- → P3
Component: Event Handling → User events and focus handling

I arrived here from https://github.com/facebook/react/issues/17909 - I ran into this issue when using React on Firefox, because React attaches all event listeners to the top of the DOM. This means that I can't use an onChange handler on the <input /> in this example when using React on Firefox, because the event will not bubble up:

<fieldset disabled>
  <legend>
    <input type="checkbox" />
  </legend>
</fieldset>

The linked issue has been closed as they consider it a browser bug, but it looks like they didn't mention it here.

Flags: needinfo?(bugs)

Olli, what do you think about comment 4?

Flags: needinfo?(bugs)
See Also: → 1653882
Severity: normal → S3
See Also: → 1835336
Status: NEW → RESOLVED
Closed: 3 years ago
Duplicate of bug: 1829874
Resolution: --- → DUPLICATE
Flags: needinfo?(smaug)
You need to log in before you can comment on or make changes to this bug.