| 178 | } |
| 179 | |
| 180 | async hide(shouldRefocusOriginalFrame) { |
| 181 | if (shouldRefocusOriginalFrame == null) shouldRefocusOriginalFrame = true; |
| 182 | |
| 183 | await this.iframePort; |
| 184 | if (!this.showing) return; |
| 185 | this.showing = false; |
| 186 | this.setIframeVisible(false); |
| 187 | if (this.focusOptions.focus) { |
| 188 | this.iframeElement.blur(); |
| 189 | if (shouldRefocusOriginalFrame) { |
| 190 | if (this.focusOptions.sourceFrameId != null) { |
| 191 | chrome.runtime.sendMessage({ |
| 192 | handler: "sendMessageToFrames", |
| 193 | frameId: this.focusOptions.sourceFrameId, |
| 194 | message: { |
| 195 | handler: "focusFrame", |
| 196 | forceFocusThisFrame: true, |
| 197 | }, |
| 198 | }); |
| 199 | } else { |
| 200 | Utils.nextTick(() => globalThis.focus()); |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | this.focusOptions = {}; |
| 205 | this.postMessage({ name: "hidden" }); // Inform the UI component that it is hidden. |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | globalThis.UIComponent = UIComponent; |