diff --git a/core/modules/widgets/blockid.js b/core/modules/widgets/blockid.js index eaec7a537..a7d361bff 100644 --- a/core/modules/widgets/blockid.js +++ b/core/modules/widgets/blockid.js @@ -37,9 +37,14 @@ BlockIdWidget.prototype.hookFocusElementEvent = function(event) { if(!event.param) return event; var id = event.param.replace('#',''); if(id !== this.id) return event; - var element = this.parentDomNode; + var selector = event.param || "", + element, + baseElement = event.event && event.event.target ? event.event.target.ownerDocument : document; + element = $tw.utils.querySelectorSafe(selector,baseElement) || this.spanDomNode; + if(!element.parentNode) return; + element = element.parentNode; // need to check if the block is before this node - if(this.previousSibling) { + if(this.previousSibling && element.previousSibling) { element = element.previousSibling; } element.focus({ focusVisible: true }); diff --git a/core/modules/widgets/link.js b/core/modules/widgets/link.js index 12fc2da23..6bb3aa4d2 100755 --- a/core/modules/widgets/link.js +++ b/core/modules/widgets/link.js @@ -168,11 +168,15 @@ LinkWidget.prototype.handleClickEvent = function(event) { event: event }); if(this.toBlockId) { - this.dispatchEvent({ - type: "tm-focus-selector", - param: "#" + this.toBlockId, - event: event, - }); + var duration = $tw.utils.getAnimationDuration(); + var self = this; + setTimeout(function() { + self.dispatchEvent({ + type: "tm-focus-selector", + param: "#" + self.toBlockId, + event: event, + }); + },duration); } if(this.domNodes[0].hasAttribute("href")) { event.preventDefault();