Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Make sure to proxy special prop ref
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebarnard1 committed Mar 27, 2018
1 parent b80568b commit 39e9d52
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
17 changes: 14 additions & 3 deletions src/components/structures/ScrollPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const ReactDOM = require("react-dom");
import PropTypes from 'prop-types';
import Promise from 'bluebird';
import { KeyCode } from '../../Keyboard';
import sdk from '../../index.js';

const DEBUG_SCROLL = false;
// var DEBUG_SCROLL = true;
Expand Down Expand Up @@ -223,7 +224,7 @@ module.exports = React.createClass({
onResize: function() {
this.props.onResize();
this.checkScroll();
this.refs.geminiPanel.forceUpdate();
if (this._gemScroll) this._gemScroll.forceUpdate();
},

// after an update to the contents of the panel, check that the scroll is
Expand Down Expand Up @@ -664,15 +665,25 @@ module.exports = React.createClass({
throw new Error("ScrollPanel._getScrollNode called when unmounted");
}

return this.refs.geminiPanel.scrollbar.getViewElement();
if (!this._gemScroll) {
// Likewise, we should have the ref by this point, but if not
// turn the NPE into something meaningful.
throw new Error("ScrollPanel._getScrollNode called before gemini ref collected");
}

return this._gemScroll.scrollbar.getViewElement();
},

_collectGeminiScroll: function(gemScroll) {
this._gemScroll = gemScroll;
},

render: function() {
const GeminiScrollbarWrapper = sdk.getComponent("elements.GeminiScrollbarWrapper");
// TODO: the classnames on the div and ol could do with being updated to
// reflect the fact that we don't necessarily contain a list of messages.
// it's not obvious why we have a separate div and ol anyway.
return (<GeminiScrollbarWrapper autoshow={true} ref="geminiPanel"
return (<GeminiScrollbarWrapper autoshow={true} wrappedRef={this._collectGeminiScroll}
onScroll={this.onScroll} onResize={this.onResize}
className={this.props.className} style={this.props.style}>
<div className="mx_RoomView_messageListWrapper">
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/elements/GeminiScrollbarWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class GeminiScrollbarWrapper extends React.Component {
// By default GeminiScrollbar allows native scrollbars to be used
// on macOS. Use forceGemini to enable Gemini's non-native
// scrollbars on all OSs.
return <GeminiScrollbar forceGemini={true} {...this.props}>
return <GeminiScrollbar ref={this.props.wrappedRef} forceGemini={true} {...this.props}>
{ this.props.children }
</GeminiScrollbar>;
}
Expand Down
9 changes: 7 additions & 2 deletions src/components/views/rooms/RoomList.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,8 @@ module.exports = React.createClass({
onShowMoreRooms: function() {
// kick gemini in the balls to get it to wake up
// XXX: uuuuuuugh.
this.refs.gemscroll.forceUpdate();
if (!this._gemScroll) return;
this._gemScroll.forceUpdate();
},

_getEmptyContent: function(section) {
Expand Down Expand Up @@ -598,14 +599,18 @@ module.exports = React.createClass({
return ret;
},

_collectGemini(gemScroll) {
this._gemScroll = gemScroll;
},

render: function() {
const RoomSubList = sdk.getComponent('structures.RoomSubList');
const GeminiScrollbarWrapper = sdk.getComponent("elements.GeminiScrollbarWrapper");

const self = this;
return (
<GeminiScrollbarWrapper className="mx_RoomList_scrollbar"
autoshow={true} onScroll={self._whenScrolling} ref="gemscroll">
autoshow={true} onScroll={self._whenScrolling} wrappedRef={this._collectGemini}>
<div className="mx_RoomList">
<RoomSubList list={[]}
extraTiles={this._makeGroupInviteTiles()}
Expand Down

0 comments on commit 39e9d52

Please sign in to comment.