Merge pull request #228 from toasted-nutbread/fix-tab-focus-changing

Fix tab focus being changed due to settings changes
This commit is contained in:
Alex Yatskov 2019-09-30 19:53:45 -07:00 committed by GitHub
commit 00d16433e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 20 deletions

View File

@ -128,7 +128,7 @@ class Frontend {
}
this.popupTimerClear();
this.searchClear();
this.searchClear(true);
}
onMouseOut(e) {
@ -138,7 +138,7 @@ class Frontend {
onFrameMessage(e) {
const handlers = {
popupClose: () => {
this.searchClear();
this.searchClear(true);
},
selectionCopy: () => {
@ -153,7 +153,7 @@ class Frontend {
}
onResize() {
this.searchClear();
this.searchClear(true);
}
onClick(e) {
@ -265,7 +265,7 @@ class Frontend {
async updateOptions() {
this.options = await apiOptionsGet(this.getOptionsContext());
if (!this.options.enable) {
this.searchClear();
this.searchClear(false);
}
}
@ -320,7 +320,7 @@ class Frontend {
textSource.cleanup();
}
if (hideResults && this.options.scanning.autoHideResults) {
this.searchClear();
this.searchClear(true);
}
this.pendingLookup = false;
@ -392,8 +392,8 @@ class Frontend {
return true;
}
searchClear() {
this.popup.hide();
searchClear(changeFocus) {
this.popup.hide(changeFocus);
this.popup.clearAutoPlayTimer();
if (this.options.scanning.selectText && this.textSourceLast) {

View File

@ -40,7 +40,7 @@ class PopupProxyHost {
createNestedPopup: ({parentId}) => this.createNestedPopup(parentId),
show: ({id, elementRect, options}) => this.show(id, elementRect, options),
showOrphaned: ({id, elementRect, options}) => this.show(id, elementRect, options),
hide: ({id}) => this.hide(id),
hide: ({id, changeFocus}) => this.hide(id, changeFocus),
setVisible: ({id, visible}) => this.setVisible(id, visible),
containsPoint: ({id, x, y}) => this.containsPoint(id, x, y),
termsShow: ({id, elementRect, writingMode, definitions, options, context}) => this.termsShow(id, elementRect, writingMode, definitions, options, context),
@ -98,9 +98,9 @@ class PopupProxyHost {
return await popup.showOrphaned(elementRect, options);
}
async hide(id) {
async hide(id, changeFocus) {
const popup = this.getPopup(id);
return popup.hide();
return popup.hide(changeFocus);
}
async setVisible(id, visible) {

View File

@ -58,11 +58,11 @@ class PopupProxy {
return await this.invokeHostApi('showOrphaned', {id, elementRect, options});
}
async hide() {
async hide(changeFocus) {
if (this.id === null) {
return;
}
return await this.invokeHostApi('hide', {id: this.id});
return await this.invokeHostApi('hide', {id: this.id, changeFocus});
}
async setVisible(visible) {

View File

@ -105,7 +105,7 @@ class Popup {
container.style.height = `${height}px`;
container.style.visibility = 'visible';
this.hideChildren();
this.hideChildren(true);
}
static getPositionForHorizontalText(elementRect, width, height, maxWidth, maxHeight, optionsGeneral) {
@ -206,16 +206,21 @@ class Popup {
this.invokeApi('orphaned');
}
hide() {
this.hideChildren();
hide(changeFocus) {
if (this.isContainerHidden()) {
changeFocus = false;
}
this.hideChildren(changeFocus);
this.hideContainer();
if (changeFocus) {
this.focusParent();
}
}
hideChildren() {
// recursively hides all children
if (this.child && !this.child.isContainerHidden()) {
this.child.hide();
hideChildren(changeFocus) {
// Recursively hides all children.
if (this.child !== null && !this.child.isContainerHidden()) {
this.child.hide(changeFocus);
}
}