fix RTL in chat using react-virtualized

This commit is contained in:
KDSBrowne 2020-02-12 14:57:59 +00:00
parent e23db63992
commit dee84c1af9

View File

@ -65,6 +65,7 @@ class MessageList extends Component {
};
this.listRef = null;
this.virualRef = null;
this.lastWidth = 0;
}
@ -74,9 +75,22 @@ class MessageList extends Component {
scrollPosition,
} = this.props;
this.scrollTo(scrollPosition);
const { childNodes } = this.messageListWrapper;
this.virualRef = childNodes ? childNodes[0].firstChild : null;
if (this.virualRef) {
this.virualRef.style.direction = document.documentElement.dir;
}
}
componentDidUpdate(prevProps) {
if (this.virualRef) {
if (this.virualRef.style.direction !== document.documentElement.dir) {
this.virualRef.style.direction = document.documentElement.dir;
}
}
const {
scrollPosition,
chatId,
@ -264,7 +278,7 @@ class MessageList extends Component {
} = this.state;
return (
[<div className={styles.messageListWrapper} key="chat-list" data-test="chatMessages">
[<div className={styles.messageListWrapper} key="chat-list" data-test="chatMessages" ref={node => this.messageListWrapper = node}>
<AutoSizer>
{({ height, width }) => {
if (width !== this.lastWidth) {