Focus the current entry earlier in the generation process (#1137)

This commit is contained in:
toasted-nutbread 2020-12-19 16:00:47 -05:00 committed by GitHub
parent d42b95a9c0
commit bef8612665
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -879,6 +879,7 @@ class Display extends EventDispatcher {
} }
let {sentence=null, optionsContext=null, focusEntry=null, scrollX=null, scrollY=null} = state; let {sentence=null, optionsContext=null, focusEntry=null, scrollX=null, scrollY=null} = state;
if (typeof focusEntry !== 'number') { focusEntry = 0; }
if (!(typeof optionsContext === 'object' && optionsContext !== null)) { if (!(typeof optionsContext === 'object' && optionsContext !== null)) {
optionsContext = this.getOptionsContext(); optionsContext = this.getOptionsContext();
state.optionsContext = optionsContext; state.optionsContext = optionsContext;
@ -943,9 +944,11 @@ class Display extends EventDispatcher {
entry.dataset.index = `${i}`; entry.dataset.index = `${i}`;
this._addEntryEventListeners(entry); this._addEntryEventListeners(entry);
container.appendChild(entry); container.appendChild(entry);
if (focusEntry === i) {
this._focusEntry(i, false);
}
} }
this._focusEntry(typeof focusEntry === 'number' ? focusEntry : 0, false);
if (typeof scrollX === 'number' || typeof scrollY === 'number') { if (typeof scrollX === 'number' || typeof scrollY === 'number') {
let {x, y} = this._windowScroll; let {x, y} = this._windowScroll;
if (typeof scrollX === 'number') { x = scrollX; } if (typeof scrollX === 'number') { x = scrollX; }