Opened 9 years ago

Closed 9 years ago

#10513 closed defect (wontfix)

Regression: Widgets' onBlur() method called even when it should not be

Reported by: lipik Owned by:
Priority: high Milestone: tbd
Component: Dijit Version: 1.4.0
Keywords: focus, manager, event, capture Cc:
Blocked By: Blocking:

Description

In version 1.4, dijit/_base/focus.js sets capturing listeners for mousedown, focus, blur events - previous versions only connected to these events.

The effect of these capturing listeners is that they are called even if the event is cancelled (via dojo.stopEvent). This is not a problem for focus/blur, as these events can't be cancelled. But mousedown can be cancelled, in which case focus does not change.

However, dijit's focus management code still calls onBlur() on the focussed widget even if the mousedown (on some other node) is cancelled. There is no way to override this behaviour either because the handlers are defined private inside registerWin, and overriding registerWin does not work because it gets called in the onLoad handler for focus.js.

This is a problem on all non-IE platforms, since IE does not support capturing events.

I am being lazy and not attaching a test case; a quick comparison of registerWin() implementation in focus.js should make the problem obvious.

Attachments (1)

10513-test.html (1.8 KB) - added by lipik 9 years ago.
test case

Download all attachments as: .zip

Change History (4)

comment:1 Changed 9 years ago by bill

What exactly is the problem that you are having?

This is working as I intended it to. Clicking the up/down arrows of a NumberSpinner causes a dojo.stopEvent() call, since the NumberSpinner handles the click by incrementing/decrementing it's value, but the NumberSpinner widget should still be marked as having "focus".

Of course dijit is misusing the word "focus" to mean that the widget is "active", not that it literally has focus.

Changed 9 years ago by lipik

Attachment: 10513-test.html added

test case

comment:2 Changed 9 years ago by lipik

The problem I have is that I am using the onBlur event on a widget to hide some content, but some specific elements on the page cancel onmousedown to avoid triggering onBlur on the widget.

This is broken on 1.4.

I've attached a simple test case to illustrate the regression.

comment:3 Changed 9 years ago by bill

Resolution: wontfix
Status: newclosed

For some reason you want to click outside of a (for example: Grid) and yet not lose literal focus or dijit's _onFocus() indicator on the Grid.

Sorry, but this just isn't the design of dijit. Clicking anywhere on a blank area of the page or on another widget is supposed to call _onBlur() on the selected widget... even if the clicked widget captures and stops the mouse down event.

Note: See TracTickets for help on using tickets.