Since `focus()` might scroll, do this after `focus()` and reflow.
175526
function restoreAndFinish() {
    traceLog.push('<finishHiding.restoreAndFinish>', '_id:' + props._id, 'state:' + STATE_TEXT[props.state]); // [DEBUG/]
    props.timerRestoreAndFinish = null;
    props.state = STATE_HIDDEN;
    traceLog.push('state:' + STATE_TEXT[props.state]); // [DEBUG/]
    traceLog.push('focusListener:ADD'); // [DEBUG/]
    props.elmTargetBody.addEventListener('focus', props.focusListener, true);
    restoreScroll(props);
    props.savedElementsScroll = null;

    if (props.options.onHide) {
      props.options.onHide.call(props.ins);
    }
    traceLog.push('_id:' + props._id, '</finishHiding.restoreAndFinish>'); // [DEBUG/]
  }
488765
function () {
                var options = autoScroll.interaction.target.options[autoScroll.interaction.prepared.name].autoScroll,
                    container = options.container || getWindow(autoScroll.interaction.element),
                    now = new Date().getTime(),
                    // change in time in seconds
                    dtx = (now - autoScroll.prevTimeX) / 1000,
                    dty = (now - autoScroll.prevTimeY) / 1000,
                    vx, vy, sx, sy;

                // displacement
                if (options.velocity) {
                  vx = options.velocity.x;
                  vy = options.velocity.y;
                }
                else {
                  vx = vy = options.speed
                }
 
                sx = vx * dtx;
                sy = vy * dty;

                if (sx >= 1 || sy >= 1) {
                    if (isWindow(container)) {
                        container.scrollBy(autoScroll.x * sx, autoScroll.y * sy);
                    }
                    else if (container) {
                        container.scrollLeft += autoScroll.x * sx;
                        container.scrollTop  += autoScroll.y * sy;
                    }

                    if (sx >=1) autoScroll.prevTimeX = now;
                    if (sy >= 1) autoScroll.prevTimeY = now;
                }

                if (autoScroll.isScrolling) {
                    cancelFrame(autoScroll.i);
                    autoScroll.i = reqFrame(autoScroll.scroll);
                }
            }
1028048
function (ev) {
        // If we're copying text, don't shift focus
        if (ev.ctrlKey || ev.altKey || ev.metaKey) {
            return;
        }

        // If we're typing into an input box somewhere, ignore
        var elements = ['input', 'select', 'textarea', 'button', 'datalist', 'keygen'];
        var do_not_refocus =
            elements.indexOf(ev.target.tagName.toLowerCase()) > -1 ||
            $(ev.target).attr('contenteditable');

        if (do_not_refocus) {
            return;
        }

        $('#kiwi .controlbox .inp').focus();
    }
27646
function() {
      var cur = select.selectionTopNode(this.container, true), start = cur;
      if (cur === false || !(!cur || cur.isPart || isBR(cur)) || !this.container.firstChild)
        return false;

      while (cur && !isBR(cur)) cur = cur.previousSibling;
      var next = cur ? cur.nextSibling : this.container.firstChild;
      if (next && next != start && next.isPart && hasClass(next, "whitespace"))
        select.focusAfterNode(next, this.container);
      else
        select.focusAfterNode(cur, this.container);

      select.scrollToCursor(this.container);
      return true;
    }
688443
def focus_prev(self):
        """"""
        w, focuspos = self.get_focus()
        prev = self._tree.prev_position(focuspos)
        if prev is not None:
            self.set_focus(prev)
1093340
function handleFocusIndexChange (newIndex, oldIndex) {
    if (newIndex === oldIndex) return;
    if (!getElements().tabs[ newIndex ]) return;
    adjustOffset();
    redirectFocus();
  }
703015
function(oThis, sDir, bUpdateFocus){
		RoadMapRenderer.scrollToNextStep(oThis, sDir, function(sFirstVisibleNodeId){
			var iIdx = sFirstVisibleNodeId.lastIndexOf("-expandend");
			if (iIdx != -1) {
				sFirstVisibleNodeId = sFirstVisibleNodeId.substring(0, iIdx);
			}
			oThis.setProperty("firstVisibleStep", sFirstVisibleNodeId, true);

			if (bUpdateFocus) {
				refreshFocus(oThis, sDir);
			}
		});
	}
495018
function redirectFocus () {
    ctrl.styleTabItemFocus = ($mdInteraction.getLastInteractionType() === 'keyboard');
    var tabToFocus = getElements().tabs[ctrl.focusIndex];
    if (tabToFocus) {
      tabToFocus.focus();
    }
  }
48273
def scroll_up(self, n, pre_dl=None, post_dl=None):
        
        self.delay(pre_dl)
        self.m.scroll(vertical=n)
        self.delay(post_dl)
776376
def focus_next(self):
        """"""
        w, focuspos = self.get_focus()
        next = self._tree.next_position(focuspos)
        if next is not None:
            self.set_focus(next)
977153
function trap(opts) {
    const { isTrapped: wasTrapped, restoreTrap } = this;
    const isTrapped = this.isTrapped = this.state.open;
    const isFirstRender = (opts && opts.firstRender);
    const wasToggled = isTrapped !== wasTrapped;
    const focusEl = (this.state.focus && document.getElementById(this.state.focus)) || this.closeEl;

    if (restoreTrap || (isTrapped && !wasTrapped)) {
        screenReaderTrap.trap(this.windowEl);
        keyboardTrap.trap(this.windowEl);
    }

    // Ensure focus is set and body scroll prevented on initial render.
    if (isFirstRender && isTrapped) {
        focusEl.focus();
        bodyScroll.prevent();
    }

    if (wasToggled) {
        cancelAsync.call(this);
        const onFinishTransition = () => {
            this.cancelTransition = undefined;

            if (isTrapped) {
                focusEl.focus();
                emitAndFire(this, 'dialog-show');
            } else {
                bodyScroll.restore();
                emitAndFire(this, 'dialog-close');

                // Reset dialog scroll position lazily to avoid jank.
                // Note since the dialog is not in the dom at this point none of the scroll methods will work.
                this.cancelScrollReset = setTimeout(() => {
                    this.dialogEl.parentNode.replaceChild(this.dialogEl, this.dialogEl);
                    this.cancelScrollReset = undefined;
                }, 20);
            }
        };

        if (isTrapped) {
            if (!isFirstRender) {
                bodyScroll.prevent();
                this.cancelTransition = transition({
                    el: this.dialogEl,
                    className: 'dialog--show',
                    waitFor: this.transitionEls
                }, onFinishTransition);
            }

            this.dialogEl.removeAttribute('hidden');
        } else {
            if (!isFirstRender) {
                this.cancelTransition = transition({
                    el: this.dialogEl,
                    className: 'dialog--hide',
                    waitFor: this.transitionEls
                }, onFinishTransition);
            }

            this.dialogEl.setAttribute('hidden', '');
        }
    }
}
79253
function (event) {
            this._hasFocus = true;
            this._setState();
            this._updateDomForState();
            var focusCallback = this._cfg.onfocus;
            if (focusCallback) {
                this.evalCallback(focusCallback);
            }
       }
234645
function(e) {
			var self = this;
			var wasFocused = self.isFocused;
	
			if (self.isDisabled) {
				self.blur();
				e && e.preventDefault();
				return false;
			}
	
			if (self.ignoreFocus) return;
			self.isFocused = true;
			if (self.settings.preload === 'focus') self.onSearchChange('');
	
			if (!wasFocused) self.trigger('focus');
	
			if (!self.$activeItems.length) {
				self.showInput();
				self.setActiveItem(null);
				self.refreshOptions(!!self.settings.openOnFocus);
			}
	
			self.refreshState();
		}
1214747
function(oThis, oEvent, sDir){
		oEvent.stopPropagation();
		oEvent.preventDefault();

		if (!oThis.sCurrentFocusedItemRefId) {
			return;
		}

		var sFollowingFocusItemId = null;
		if (oThis.sLastVisibleItemId && ((oThis.sCurrentFocusedItemRefId == oThis.sLastVisibleItemId && sDir == "next") || sDir == "last")) {
			sFollowingFocusItemId = oThis.getId() + "-ovrflw";
		} else if (oThis.sLastVisibleItemId && oThis.sCurrentFocusedItemRefId == oThis.getId() + "-ovrflw" && sDir == "prev") {
			sFollowingFocusItemId = oThis.sLastVisibleItemId;
		} else {
			var sFoo = sDir + "All";
			var bIsJumpToEnd = false;
			if (sDir == "first") {
				sFoo = "prevAll";
				bIsJumpToEnd = true;
			} else if (sDir == "last") {
				sFoo = "nextAll";
				bIsJumpToEnd = true;
			}

			var jCurrentFocusItem = jQuery(document.getElementById(oThis.sCurrentFocusedItemRefId));
			var jFollowingItems = jCurrentFocusItem[sFoo](":visible");

			sFollowingFocusItemId = jQuery(jFollowingItems.get(bIsJumpToEnd ? jFollowingItems.length - 1 : 0)).attr("id");
		}
		if (sFollowingFocusItemId) {
			oThis.sCurrentFocusedItemRefId = sFollowingFocusItemId;
			document.getElementById(sFollowingFocusItemId).focus();
		}
	}
701910
def focus_next(self, count=1):
        "  "
        panes = self.panes
        if panes:
            self.active_pane = panes[(panes.index(self.active_pane) + count) % len(panes)]
        else:
            self.active_pane = None
549090
function(oThis, sDir){
		if (!oThis.sCurrentFocusedStepRefId) {
			return;
		}

		if (sDir && !RoadMapRenderer.isVisibleRef(oThis, oThis.sCurrentFocusedStepRefId)) {
			focusStep(null, oThis, sDir);
		} else {
			document.getElementById(oThis.sCurrentFocusedStepRefId + "-box").focus();
		}
	}
169953
function(inTop) {
		this.stop();
		if (this.translateOptimized) {
			var m = this.$.scrollMath;
			m.setScrollY(-inTop);
			m.stabilize();
		} else {
			this.inherited(arguments);
		}
	}