[MM-52171] webapp: Make rhs_card reloading when card body is changed (#23612)

This commit is contained in:
Yusuke Nemoto 2024-02-15 19:50:39 +09:00 committed by GitHub
parent 114b3dc8d2
commit d3b799eaa5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 4 deletions

View File

@ -31,7 +31,9 @@ exports[`comoponents/rhs_card/RhsCard should match on post when no plugin defini
<div
className="info-card"
>
<Connect(Markdown) />
<Connect(Markdown)
message=""
/>
</div>
<div
className="d-flex post-card--info"
@ -135,7 +137,9 @@ exports[`comoponents/rhs_card/RhsCard should match on post when plugin defining
<div
className="info-card"
>
<Connect(Markdown) />
<Connect(Markdown)
message=""
/>
</div>
<div
className="d-flex post-card--info"
@ -239,7 +243,9 @@ exports[`comoponents/rhs_card/RhsCard should match on post when plugin defining
<div
className="info-card"
>
<Connect(Markdown) />
<Connect(Markdown)
message=""
/>
</div>
<div
className="d-flex post-card--info"

View File

@ -1,6 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import deepEqual from 'fast-deep-equal';
import React from 'react';
import type {ReactNode} from 'react';
import Scrollbars from 'react-custom-scrollbars';
@ -80,6 +81,9 @@ export default class RhsCard extends React.Component<Props, State> {
}
shouldComponentUpdate(nextProps: Props, nextState: State) {
if (!deepEqual(nextProps.selected?.props?.card, this.props.selected?.props?.card)) {
return true;
}
if (nextState.isScrolling !== this.state.isScrolling) {
return true;
}
@ -124,7 +128,7 @@ export default class RhsCard extends React.Component<Props, State> {
if (!content) {
content = (
<div className='info-card'>
<Markdown message={selected.props && selected.props.card}/>
<Markdown message={(selected.props && selected.props.card) || ''}/>
</div>
);
}