Adjust LeftPane height when NetworkDialog pops out of view
This commit is contained in:
parent
50a18aebf1
commit
e716652b94
2 changed files with 45 additions and 32 deletions
|
@ -1,5 +1,6 @@
|
||||||
|
import Measure, { BoundingRect, MeasuredComponentProps } from 'react-measure';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { AutoSizer, List } from 'react-virtualized';
|
import { List } from 'react-virtualized';
|
||||||
import { debounce, get } from 'lodash';
|
import { debounce, get } from 'lodash';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -54,6 +55,12 @@ export class LeftPane extends React.Component<PropsType> {
|
||||||
public containerRef = React.createRef<HTMLDivElement>();
|
public containerRef = React.createRef<HTMLDivElement>();
|
||||||
public setFocusToFirstNeeded = false;
|
public setFocusToFirstNeeded = false;
|
||||||
public setFocusToLastNeeded = false;
|
public setFocusToLastNeeded = false;
|
||||||
|
public state = {
|
||||||
|
dimensions: {
|
||||||
|
height: 0,
|
||||||
|
width: 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
public renderRow = ({
|
public renderRow = ({
|
||||||
index,
|
index,
|
||||||
|
@ -157,6 +164,10 @@ export class LeftPane extends React.Component<PropsType> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public handleResize = ({ bounds }: { bounds: BoundingRect }) => {
|
||||||
|
this.setState({ dimensions: bounds });
|
||||||
|
};
|
||||||
|
|
||||||
public handleFocus = () => {
|
public handleFocus = () => {
|
||||||
const { selectedConversationId } = this.props;
|
const { selectedConversationId } = this.props;
|
||||||
const { current: container } = this.containerRef;
|
const { current: container } = this.containerRef;
|
||||||
|
@ -327,36 +338,34 @@ export class LeftPane extends React.Component<PropsType> {
|
||||||
// It also ensures that we scroll to the top when switching views.
|
// It also ensures that we scroll to the top when switching views.
|
||||||
const listKey = showArchived ? 1 : 0;
|
const listKey = showArchived ? 1 : 0;
|
||||||
|
|
||||||
|
const { height, width } = this.state.dimensions;
|
||||||
|
|
||||||
// Note: conversations is not a known prop for List, but it is required to ensure that
|
// Note: conversations is not a known prop for List, but it is required to ensure that
|
||||||
// it re-renders when our conversation data changes. Otherwise it would just render
|
// it re-renders when our conversation data changes. Otherwise it would just render
|
||||||
// on startup and scroll.
|
// on startup and scroll.
|
||||||
const list = (
|
const list = (
|
||||||
<div
|
<div
|
||||||
|
aria-live="polite"
|
||||||
className="module-left-pane__list"
|
className="module-left-pane__list"
|
||||||
key={listKey}
|
key={listKey}
|
||||||
aria-live="polite"
|
onFocus={this.handleFocus}
|
||||||
|
onKeyDown={this.handleKeyDown}
|
||||||
|
ref={this.containerRef}
|
||||||
role="group"
|
role="group"
|
||||||
tabIndex={-1}
|
tabIndex={-1}
|
||||||
ref={this.containerRef}
|
|
||||||
onKeyDown={this.handleKeyDown}
|
|
||||||
onFocus={this.handleFocus}
|
|
||||||
>
|
>
|
||||||
<AutoSizer>
|
|
||||||
{({ height, width }) => (
|
|
||||||
<List
|
<List
|
||||||
ref={this.listRef}
|
|
||||||
onScroll={this.onScroll}
|
|
||||||
className="module-left-pane__virtual-list"
|
className="module-left-pane__virtual-list"
|
||||||
conversations={conversations}
|
conversations={conversations}
|
||||||
height={height}
|
height={height}
|
||||||
|
onScroll={this.onScroll}
|
||||||
|
ref={this.listRef}
|
||||||
rowCount={length}
|
rowCount={length}
|
||||||
rowHeight={68}
|
rowHeight={68}
|
||||||
tabIndex={-1}
|
|
||||||
rowRenderer={this.renderRow}
|
rowRenderer={this.renderRow}
|
||||||
|
tabIndex={-1}
|
||||||
width={width}
|
width={width}
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
</AutoSizer>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -390,7 +399,9 @@ export class LeftPane extends React.Component<PropsType> {
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="module-left-pane">
|
<Measure bounds={true} onResize={this.handleResize}>
|
||||||
|
{({ measureRef }: MeasuredComponentProps) => (
|
||||||
|
<div className="module-left-pane" ref={measureRef}>
|
||||||
<div className="module-left-pane__header">
|
<div className="module-left-pane__header">
|
||||||
{showArchived ? this.renderArchivedHeader() : renderMainHeader()}
|
{showArchived ? this.renderArchivedHeader() : renderMainHeader()}
|
||||||
</div>
|
</div>
|
||||||
|
@ -399,6 +410,8 @@ export class LeftPane extends React.Component<PropsType> {
|
||||||
{renderUpdateDialog()}
|
{renderUpdateDialog()}
|
||||||
{this.renderList()}
|
{this.renderList()}
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
</Measure>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11644,7 +11644,7 @@
|
||||||
"rule": "React-createRef",
|
"rule": "React-createRef",
|
||||||
"path": "ts/components/LeftPane.js",
|
"path": "ts/components/LeftPane.js",
|
||||||
"line": " this.listRef = react_1.default.createRef();",
|
"line": " this.listRef = react_1.default.createRef();",
|
||||||
"lineNumber": 15,
|
"lineNumber": 16,
|
||||||
"reasonCategory": "usageTrusted",
|
"reasonCategory": "usageTrusted",
|
||||||
"updated": "2019-11-05T01:14:21.081Z",
|
"updated": "2019-11-05T01:14:21.081Z",
|
||||||
"reasonDetail": "Used for focus management"
|
"reasonDetail": "Used for focus management"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue