Wait for onDocumentFocus to happen before setting section range

Bug: 65928
Change-Id: If76408b6b89541f0ecb065d4860e0652b6bdebb5
This commit is contained in:
Ed Sanders 2014-06-15 12:57:14 +01:00
parent 1c0f331c70
commit 71395e1fa4

View file

@ -1453,7 +1453,11 @@ ve.init.mw.Target.prototype.restoreEditSection = function () {
offset = surfaceModel.getDocument().data.getNearestContentOffset(
offsetNode.getModel().getOffset(), 1
);
surfaceModel.setSelection( new ve.Range( offset ) );
// onDocumentFocus is debounced, so wait for that to happen before setting
// the model selection, otherwise it will get reset
this.surface.getView().once( 'focus', function () {
surfaceModel.setSelection( new ve.Range( offset ) );
} );
// Scroll to heading:
// Wait for toolbar to animate in so we can account for its height
setTimeout( function () {