Fix checkbox/radio shared editor on Mac #1459
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Editor: wrap checkbox and radio button shared editors on Mac
In OS X form controls are not considered focusable elements. Some browsers
(Safari, Firefox) adopt this decision:
whatwg/html/issues/4356
https://bugzilla.mozilla.org/show_bug.cgi?id=1524863
https://bugs.webkit.org/show_bug.cgi?id=22261
The resulting implementation is broken - you can call
focus()
on a checkboxand it will be focused, but clicking on a checkbox does not focus it. Further,
clicking on a focused checkbox blurs it. To overcome these challenges
checkboxes and radios are wrapped in a div that can receive focus (and blur)
in a consistent manner. Without the wrapper a valid blur is indistinguishable from an invalid blur. With the wrapper the blur event's
target
andrelatedTarget
enable reliably identifying invalid blurs and ignoring them.Notes
event
object;event.target
andevent.relatedTarget
are crucial for this solution. In testing withdijit/form/CheckBox
anddijit/form/RadioButton
functionality remains the same.dgrid/Editor.js
Line 276 in 3a7416f
cmp.focus()
would either callHTMLInputElement#focus
or a widget'sfocus
method, with this PR the widget'sfocusNode
is used, soHTMLInputElement#focus
is always calleddgrid/Editor.js
Line 766 in 3a7416f
on.pausable(cmp, 'blur', onblur)
would listen for a widget'sblur
event ifcmp
was a widget. With this PR a listener forblur
is registered directly on the widget'sfocusNode
.has('mac')
is true (1, 2) without further detection of which browser. The fix is unnecessary in unaffected browsers, but in testing works fine.Fixes #1458