Closed Bug 915962 Opened 11 years ago Closed 9 years ago

Space to scroll region does not work on elements with tabIndex set

Categories

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

23 Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla40
Tracking Status
firefox40 --- fixed

People

(Reporter: nicholas.j.santos, Assigned: ehsan.akhgari)

References

Details

(Whiteboard: [bugday-20150710])

Attachments

(3 files, 1 obsolete file)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36

Steps to reproduce:

Here is a page that demonstrates the issue:
http://jsfiddle.net/gzEJc/2/

Repro steps:
1) Create a div element with overflow: auto, overflowing content, and tabIndex = -1
2) Click into that element
3) Hit the spacebar


Actual results:

Nothing happens. 


Expected results:

The div should scroll down.

This works as expected on Chrome, Safari, and IE10.
Notice that using arrow keys to scroll does work on Gecko. It's just the spacebar-based scrolling that's broken.
Real user agent string is
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0

though I checked that the issue is reproducible on both Windows and OSX.
Based on discussion in https://github.com/reddit/reddit/issues/607 this is also a regression in FF17.
I can reproduce since Version 1.0 at least.

So, I think this is not a regression.
I am seeing this bug in Firefox nightly 27.0a1 (2013-10-02), Mac OS X (10.8.5)
I think this bug and bug 102663 should be fixed by inverting the spacebar logic: 

from:   scroll if     [document, html link, or xhtml link]
to:     scroll if not [editable or form element]

https://hg.mozilla.org/mozilla-central/file/68e752bfd992/dom/xbl/nsXBLPrototypeHandler.cpp#l481

ehsan, are you interested in fixing this?
Status: UNCONFIRMED → NEW
Component: General → Event Handling
Ever confirmed: true
Flags: needinfo?(ehsan)
OS: Windows 7 → All
Hardware: x86_64 → All
Sure, but my plate is pretty full these days, so it may be a while before I can get to this.  Leaving the needinfo for now...
Assignee: nobody → ehsan
Blocks: 102663
Flags: needinfo?(ehsan)
This is based on test_bug549262.html.
Attachment #8594397 - Flags: review?(roc)
Comment on attachment 8594396 [details] [diff] [review]
Part 1: Allow pressing space to scroll the document if an editable element or form control is not focused

Review of attachment 8594396 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/xbl/nsXBLPrototypeHandler.cpp
@@ +484,5 @@
> +    // If the focus is in a form control, don't scroll.
> +    nsCOMPtr<nsIFormControl> formControl =
> +      do_QueryInterface(focusedContent);
> +    if (formControl) {
> +      return NS_OK;

What if the focus is on content that's a descendant of the form control, e.g. a particular chunk of text in a <button>? Maybe that can't happen normally, but I think it could happen if a page programmatically sets the selection.

Anyway this seems a little fragile to me. Seems like we should bail out here if there is any form control ancestor. Or maybe form controls should be prevenDefault()ing the space-key events they consume?
Attachment #8594396 - Flags: review?(roc)
I think it makes sense to look for a form control ancestor.  I'll do that.
Backed out for crashing whenever you press spacebar with nothing focused.

http://hg.mozilla.org/mozilla-central/rev/41cda3ce8c98
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Depends on: 1180761
QA Whiteboard: [good first verify]
QA Whiteboard: [good first verify] → [good first verify][bugday-20150710]
Whiteboard: [bugday-20150710]
I used tabindex in div element,the scrolling was not done by the spacebar. It was found on firefox nightly( 26.0a1)windows 32 bit:

BuildID	        20130912030201
User Agent 	Mozilla/5.0 (Windows NT 6.3; rv:26.0) Gecko/20100101 Firefox/26.0

And I found scrolling with spacebar is working fine with tabindex set, on latest beta 40.0b3

Build ID 	20150709163524
User Agent 	Mozilla/5.0 (Windows NT 6.3; rv:40.0) Gecko/20100101 Firefox/40.0

[bugday-20150710]
I have reproduced this bug with Firefox Nightly 26.0a1 on Windows 7(64-bit) with the instructions from comment 0.

Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0

Verified as fixed with Latest Firefox Aurora 45.0a2 (Build ID : 20160115004002)

Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0

[testday-20160115]
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: