Fix paste sequence in Firefox

It appears that if the pasteTarget is given focus too close to the
range being set it may not take effect in time. Moving up to before
any of the selection setting logic seems to fix the issue.

Bug: 58283
Change-Id: I9bfb0ab6952863496fb3548e6804cb347d52cc57
This commit is contained in:
Ed Sanders 2013-12-10 19:15:04 +00:00
parent 7e9f214acd
commit 333166e818

View file

@ -839,6 +839,10 @@ ve.ce.Surface.prototype.beforePaste = function ( e ) {
ve.dm.converter.internalList = doc.getInternalList();
ve.dm.converter.getDomSubtreeFromData( context, this.$pasteTarget[0] );
// Giving the paste target focus too late can cause problems in FF (!?)
// so do it up here.
this.$pasteTarget[0].focus();
rangyRange = rangy.createRange( this.getElementDocument() );
// Assume that the DM node only generated one child
textNode = this.$pasteTarget.children().contents()[0];
@ -847,7 +851,6 @@ ve.ce.Surface.prototype.beforePaste = function ( e ) {
rangyRange.setEnd( textNode, textEnd );
sel = rangy.getSelection( this.getElementDocument() );
sel.removeAllRanges();
this.$pasteTarget[0].focus();
sel.addRange( rangyRange, false );
this.beforePasteData.context = context;