Skip to content

Commit a254d50

Browse files
committed
Add compatibility with Hyper PR #1705 and #1680
1 parent 6a9ece0 commit a254d50

File tree

1 file changed

+28
-16
lines changed

1 file changed

+28
-16
lines changed

index.js

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,18 @@ exports.mapTermsState = (state, map) => {
367367
};
368368

369369
exports.getTermGroupProps = (uid, parentProps, props) => {
370-
const { sortedSessionGroups, onMoveToPane, onSwitchWithActiveSession } = parentProps;
371-
return Object.assign({}, props, {sortedSessionGroups: sortedSessionGroups[uid]});
370+
const { sortedSessionGroups, activeRootGroup } = parentProps;
371+
if (!sortedSessionGroups[activeRootGroup]) {
372+
return props;
373+
}
374+
return Object.assign(props, {sortedSessionGroups: sortedSessionGroups[activeRootGroup]});
372375
};
373376

374377
exports.getTermProps = (uid, parentProps, props) => {
375378
const { termGroup, sortedSessionGroups } = parentProps;
379+
if (!sortedSessionGroups) {
380+
return props;
381+
}
376382
const index = sortedSessionGroups.indexOf(termGroup.uid);
377383
// Only 1-9 keys are used and if there is more than 9 terms, number 9 is reserved to the last term
378384
let termShorcutNum = 0;
@@ -403,6 +409,9 @@ exports.decorateTerms = (Terms, { React, notify, Notification }) => {
403409
}
404410

405411
handleFocusActive() {
412+
if (!this.terms.getActiveTerm) {
413+
return;
414+
}
406415
const term = this.terms.getActiveTerm();
407416
if (term) {
408417
term.focus();
@@ -418,6 +427,9 @@ exports.decorateTerms = (Terms, { React, notify, Notification }) => {
418427
}
419428

420429
attachKeyListeners() {
430+
if (!this.terms.getActiveTerm) {
431+
return;
432+
}
421433
const term = this.terms.getActiveTerm();
422434
if (!term) {
423435
return;
@@ -509,7 +521,7 @@ exports.decorateTerm = (Term, { React, notify }) => {
509521
return class extends React.Component {
510522
constructor(props, context) {
511523
super(props, context);
512-
this.onTermRef = this.onTermRef.bind(this);
524+
this.onDecorated = this.onDecorated.bind(this);
513525
this.onMouseEnter = this.onMouseEnter.bind(this);
514526
}
515527

@@ -520,24 +532,23 @@ exports.decorateTerm = (Term, { React, notify }) => {
520532
}
521533
}
522534

523-
componentDidMount() {
524-
debug('Attach mouse handler');
525-
if (!this.term) {
526-
debug('No term ref');
527-
return;
528-
}
529-
const doc = this.term.getTermDocument();
530-
doc.body.onmouseenter = this.onMouseEnter;
531-
}
532-
533-
onTermRef(term) {
535+
onDecorated(term) {
534536
debug('Keep term ref');
535537
this.term = term;
538+
if (this.term && this.term.getTermDocument) {
539+
const doc = this.term.getTermDocument();
540+
doc.body.onmouseenter = this.onMouseEnter;
541+
}
536542
}
537543

538544
render () {
545+
const props = {
546+
ref: this.onDecorated,
547+
onDecorated: this.onDecorated
548+
};
549+
539550
if (!config.showIndicators) {
540-
return React.createElement(Term, Object.assign({}, this.props, {ref: this.onTermRef}));
551+
return React.createElement(Term, Object.assign({}, this.props, props));
541552
}
542553
const myCustomChildrenBefore = React.createElement(
543554
'div',
@@ -549,7 +560,8 @@ exports.decorateTerm = (Term, { React, notify }) => {
549560
const customChildrenBefore = this.props.customChildrenBefore
550561
? Array.from(this.props.customChildrenBefore).concat(myCustomChildrenBefore)
551562
: myCustomChildrenBefore;
552-
return React.createElement(Term, Object.assign({}, this.props, {customChildrenBefore, ref: this.onTermRef}));
563+
props.customChildrenBefore = customChildrenBefore;
564+
return React.createElement(Term, Object.assign({}, this.props, props));
553565
}
554566
}
555567
}

0 commit comments

Comments
 (0)