Search and Top Navigation
#9890 closed bug (fixed)
Opened March 05, 2014 08:35PM UTC
Closed March 07, 2014 02:32PM UTC
Last modified March 07, 2014 02:33PM UTC
Slider: Default anchor action not prevented when disabled
Reported by: | jcarlson | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.11.0 |
Component: | ui.slider | Version: | 1.10.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Up until 1.10.0, the ui.slider widget would intercept 'click' events on the <a> tag used for the draggable slider handle. Starting with 1.10.1, the ui.slider widget utilizes the widget factory's '_on' method to delegate events.
Using the direct event handling in 1.10.0, the 'click' event was handled and the default action cancelled regardless of the state of the slider widget (enabled/disabled).
In 1.10.1, the '_on' method only invokes the 'click' handler if the slider widget is enabled (per documentation). However, the slider widget does not expose any configurable option to control this behavior. When a user clicks on the slider handle in a disabled state, the 'click' event escapes to the browser and the browser attempts to navigate to '#' as specified by the <a> tag's href attribute.
When using single-page application frameworks with a router, like Spine or Backbone, this causes the router to pick up on the "change" in route and navigate the user away from the current screen.
To correct this problem, the slider widget should either revert to direct event binding for the 'click' event or specify that the '_on' method disregard the disabled state of the widget using the 'suppressDisabledCheck' argument.
Alternatively, the slider widget could expose a configurable option to govern whether the widget follows legacy behavior (always intercept and cancel clicks on the <a>) or the new behavior (only intercept clicks on the <a> when the slider is not disabled).
Here are some relevant sections of code to look at:
In UI 1.10.0, ui.slider uses direct event binding:
https://github.com/jquery/jquery-ui/blob/1.10.0/ui/jquery.ui.slider.js#L97-L119
In 1.10.1, ui.slider delegates to ui.widget._on:
https://github.com/jquery/jquery-ui/blob/1.10.1/ui/jquery.ui.slider.js#L141
The ui.widgets._on method ignores the click handler callback when the widget is disabled:
https://github.com/jquery/jquery-ui/blob/1.10.1/ui/jquery.ui.widget.js#L386-L398
Attachments (0)
Change History (4)
Changed March 05, 2014 09:13PM UTC by comment:1
status: | new → open |
---|---|
summary: | Regression on default action when slider is disabled → Slider: Default anchor action not prevented when disabled |
Changed March 05, 2014 09:16PM UTC by comment:2
Changed March 07, 2014 02:32PM UTC by comment:3
resolution: | → fixed |
---|---|
status: | open → closed |
Slider: Switch handles from <a href="#"> to <span tabindex="0">
Fixes #9890
Closes gh-1207
Changeset: dfc5c34320691bd113250795243ea8b025b1f516
Changed March 07, 2014 02:33PM UTC by comment:4
milestone: | none → 1.11.0 |
---|