Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 366312

Summary: [firefox] right-clicking outside of the selection causes the caret to move
Product: [ECD] Orion Reporter: Mihai Sucan <mihai.sucan>
Component: EditorAssignee: Mihai Sucan <mihai.sucan>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipse.felipe, mihai.sucan
Version: unspecified   
Target Milestone: 0.4 M2   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Mihai Sucan CLA 2011-12-10 11:31:50 EST
STR:

1. open Orion.
2. make a selection or place the caret anywhere you want in the document.
3. right-click on a different line.

Expected result: nothing happens.

Actual result: the text color of the selection changes and the caret moves to the mouse location.

Cause: the right click event is not prevented, the caret location changes and the DOM selection is lost (hence the text color of the selection changes).

This is caused by Mozilla bug 709476:
https://bugzilla.mozilla.org/show_bug.cgi?id=709476
Comment 1 Mihai Sucan CLA 2011-12-10 11:59:59 EST
Proposed change:

https://github.com/mihaisucan/orion.client/tree/bug-366312

We can't use preventDefault(), so the only solution I came up with was to update the DOM selection when needed.

Please let me know if further changes are needed. Thank you!
Comment 2 Felipe Heidrich CLA 2011-12-12 16:46:17 EST
Looks fine, not sure I would worry about the "if (timeDiff <= this._clickTime)" test, 

go ahead and release it.

Thank you
Comment 3 Mihai Sucan CLA 2011-12-13 12:48:33 EST
(In reply to comment #2)
> Looks fine, not sure I would worry about the "if (timeDiff <= this._clickTime)"
> test, 
> 
> go ahead and release it.

Thank you for reviewing the code!

Landed:

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=ea880f5922f1bcdf09fd5fa1e9d238355d36cf89

The timeDiff check is needed for when you right-click then you press the contextmenu key after some long delay. The workaround to call _updateDOMSelection() is only needed when the context menu is invoked from right-click within the allocated time.