Closed Bug 688599 Opened 13 years ago Closed 13 years ago

jquery-ui depends on an onselectstart to function properly

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: john.carlson3, Unassigned)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:6.0.2) Gecko/20100101 Firefox/6.0.2
Build ID: 20110902133214

Steps to reproduce:

wrote a page with a simple jquery portlet, used DataTables or just my own form in the portlet.


Actual results:

The text field didn't allow me to enter text, thus I couldn't search the data table


Expected results:

I should be able to enter text in the text field, AFAIK.  This works in Safari and Chrome
Attachment #561866 - Attachment mime type: text/plain → text/html
Confirm it fails in 3.6 and latest nightly.

Works in Chrome and IE

Also fails in SeaMonkey so kicking to core for further triage
OS: Mac OS X → All
Product: Firefox → Core
QA Contact: general → general
Version: 6 Branch → Trunk
This works fine if I tab to the form.

If I _click_ on the form it looks like the page does something that prevents the textfield from getting focus.

In particular, the page has this:

		$( ".column" ).disableSelection();

where <div class="column"> is an ancestor of the textfield.  The implementation of disableSelection in jquery-ui is:

  disableSelection: function() {
    return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
                        ".ui-disableSelection", 
      function( event ) {
        event.preventDefault();
      });
  },

$.support.selectstart is set to true if and only if <div> elements have an "onselectstart" property.  In that case, disableSelection prevents the default action of selectstart events.  Otherwise it prevents the default action of mousedown events.

It so happens that WebKit (hence Chrome) has an onselectstart property on elements.  So in WebKit, that's the event whose default action is prevented.

IE likewise has an onselectstart property.

We do _not_ have such a property, and there is none defined in HTML5.  So in Gecko the page prevents the default action of the mousedown.  In this case that default action happens to be "move the focus".... so the focus doesn't move.  This part looks correct to me.

Fundamentally, this is a bug in jquery-ui and should be reported to them.  But maybe the specs needs to define onselectstart?
Component: General → Event Handling
QA Contact: general → events
And in particular, looks like jquery-ui realized that the onmousedown thing caused problems in browsers.... so they decided to only do it in some browsers.  See https://github.com/jquery/jquery-ui/commit/47e312b238453c6dae1e15e2828dfd27b8079408
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: can't enter text in a jquery sortable/portlet. Works in safari and chrome → jquery-ui depends on an onselectstart to function properly
Preventing the user from selecting stuff is evil.  Are there any other use cases for
onselectstart?
(In reply to Mats Palmgren [:mats] from comment #5)
> Preventing the user from selecting stuff is evil.  Are there any other use
> cases for onselectstart?

I don't know of other use cases, but the only reason we want it for jQuery UI is to prevent text selection in draggable elements. Without the prevention in place, it's really common for text to get selected during a drag.
We're going to remove this functionality from jQuery UI. You can probably close this as won't fix now.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → INVALID
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.