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

View File

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

View File

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

View File

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