This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 29503 - Element Click should specify how to handle multi selects
Summary: Element Click should specify how to handle multi selects
Status: NEW
Alias: None
Product: Browser Test/Tools WG
Classification: Unclassified
Component: WebDriver (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Browser Testing and Tools WG
QA Contact: Browser Testing and Tools WG
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 20860
  Show dependency treegraph
 
Reported: 2016-02-24 22:04 UTC by clmartin@microsoft.com
Modified: 2016-09-20 20:28 UTC (History)
3 users (show)

See Also:


Attachments

Description clmartin@microsoft.com 2016-02-24 22:04:13 UTC
Currently the spec doesn't specify how Click() should work on a multi-select option. In Chrome and Firefox, they perform a toggle instead of a click command. This means the option that has been "clicked" actually just toggles that option on/off. In Edge an actual click happens, which in a multi-select means the same element is clicked and the selection is never cleared.
Comment 1 John Jansen 2016-09-19 16:40:39 UTC
note: dom event discussion with select lists as well...
Comment 2 Simon Stewart 2016-09-19 16:41:14 UTC
Chrome and Firefox are doing the Right Thing, IMO. "Click" is a "do what I mean" API.
Comment 3 clmartin@microsoft.com 2016-09-20 20:28:08 UTC
I'm curious why Chrome/Firefox's implementation is thought to be the right thing? A user cannot reproduce what Chrome/Firefox do in this case. If a user clicks an item in a multi-select it selects that item. If they click it again it doesn't deselect that item. If the goal is to be true to what a browser/user would actually do/see when clicking a mouse on a multi-select then Firefox/Chrome wouldn't actually be doing what's right.

Here is a jsfiddle example:
https://jsfiddle.net/oxen65bj/

Click once: Selects that option
Click same option 2nd time: Selects that option
Ctrl + Click same option: Deselects that option
Ctrl + Click other options: Selects those options in addition to the original option
Shift + Click: Select a range from the currently selected option to the clicked option

The appropriate way to deselect an option is to hold Ctrl and then Click the option you had selected. I would argue that this should be the approach. It would also offer other ways for users to do selections (seen above using Ctrl/Shift to select multiple).

If one of the goals is to have WebDriver truly implemented as how the browser would do a click or send a key and fire events and such, I'd argue this is the route we should take. Otherwise we have a one-off functionality for clicking when it's a multi-select that doesn't actually do a click but instead some magic behind the scenes.