Expose focusActiveTerm function to window

This commit is contained in:
hector 2019-08-16 11:43:47 +08:00 committed by Benjamin Staneck
parent 9ba47135a8
commit 7074cbe29b
2 changed files with 5 additions and 2 deletions

View file

@ -27,11 +27,12 @@ export default class Header extends React.PureComponent {
this.props.onChangeTab(active);
}
handleHeaderMouseDown(ev) {
handleHeaderMouseDown() {
// the hack of all hacks, this prevents the term
// iframe from losing focus, for example, when
// the user drags the nav around
ev.preventDefault();
// Fixed by calling window.focusActiveTerm(), thus we can support drag tab
// ev.preventDefault();
// persist start positions of a potential drag motion
// to differentiate dragging from clicking
@ -111,6 +112,7 @@ export default class Header extends React.PureComponent {
<header
className={`header_header ${isMac && 'header_headerRounded'}`}
onMouseDown={this.handleHeaderMouseDown}
onMouseUp={() => window.focusActiveTerm()}
onDoubleClick={this.handleMaximizeClick}
>
{!isMac && (

View file

@ -87,6 +87,7 @@ class Hyper extends React.PureComponent {
onTermsRef(terms) {
this.terms = terms;
window.focusActiveTerm = this.handleFocusActive;
}
componentDidUpdate(prev) {