From 11b932cee4e57376f8b975b65b13dad483ec5dd4 Mon Sep 17 00:00:00 2001 From: undefined Date: Thu, 6 Nov 2025 21:39:29 +0800 Subject: [PATCH] ui: fix messagepad render, fix #1074 --- packages/ui-default/build/config/webpack.ts | 1 - .../MessagePadDialogueContentContainer.jsx | 22 +++++++++---------- .../MessagePadDialogueListContainer.jsx | 6 +---- .../messagepad/MessagePadInputContainer.jsx | 4 ++-- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/packages/ui-default/build/config/webpack.ts b/packages/ui-default/build/config/webpack.ts index 088178460..d6c04861f 100644 --- a/packages/ui-default/build/config/webpack.ts +++ b/packages/ui-default/build/config/webpack.ts @@ -286,7 +286,6 @@ export default async function (env: { watch?: boolean, production?: boolean, mea }), new ExtractCssPlugin({ filename: `[name]-${version}.css?[fullhash:6]`, - chunkFilename: '[name]-[chunkhash:6].chunk.css', }), new WebpackManifestPlugin({}), new webpack.IgnorePlugin({ resourceRegExp: /(^\.\/locale$)/ }), diff --git a/packages/ui-default/components/messagepad/MessagePadDialogueContentContainer.jsx b/packages/ui-default/components/messagepad/MessagePadDialogueContentContainer.jsx index 4e1466ac0..8fb7368c1 100644 --- a/packages/ui-default/components/messagepad/MessagePadDialogueContentContainer.jsx +++ b/packages/ui-default/components/messagepad/MessagePadDialogueContentContainer.jsx @@ -18,12 +18,9 @@ const mapStateToProps = (state) => ({ // eslint-disable-next-line react-refresh/only-export-components export default connect(mapStateToProps)(class MessagePadDialogueContentContainer extends React.PureComponent { - componentDidMount() { - $(this.refs.list).scrollLock({ strict: true }); - } - componentDidUpdate(prevProps) { - const node = this.refs.list; + const node = this.state.ref; + if (this.props.activeId !== prevProps.activeId) { this.scrollToBottom = true; this.scrollWithAnimation = false; @@ -32,6 +29,8 @@ export default connect(mapStateToProps)(class MessagePadDialogueContentContainer this.scrollWithAnimation = true; } else this.scrollToBottom = false; + if (!node) return; + $(this.state.ref).scrollLock({ strict: true }); if (this.scrollToBottom) { const targetScrollTop = node.scrollHeight - node.offsetHeight; if (this.scrollWithAnimation) { @@ -93,14 +92,13 @@ export default connect(mapStateToProps)(class MessagePadDialogueContentContainer return ( <>
- { this.props.item - && ( - - {`${this.props.item.udoc.uname}(UID: ${this.props.item.udoc._id})`} - - )} + {this.props.item && ( + + {`${this.props.item.udoc.uname}(UID: ${this.props.item.udoc._id})`} + + )}
-
    +
      { this.setState({ ...this.state, ref }); }}> {this.renderInner()}
    diff --git a/packages/ui-default/components/messagepad/MessagePadDialogueListContainer.jsx b/packages/ui-default/components/messagepad/MessagePadDialogueListContainer.jsx index 6354efd96..416a9b0c2 100644 --- a/packages/ui-default/components/messagepad/MessagePadDialogueListContainer.jsx +++ b/packages/ui-default/components/messagepad/MessagePadDialogueListContainer.jsx @@ -23,10 +23,6 @@ const mapDispatchToProps = (dispatch) => ({ // eslint-disable-next-line react-refresh/only-export-components export default connect(mapStateToProps, mapDispatchToProps)(class MessagePadDialogueListContainer extends React.PureComponent { - componentDidMount() { - $(this.refs.list).scrollLock({ strict: true }); - } - render() { const orderedDialogues = _.orderBy( _.values(this.props.dialogues), @@ -36,7 +32,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(class MessagePadDial 'desc', ); return ( -
      +
        $(ref).scrollLock({ strict: true })}> {_.map(orderedDialogues, (dialogue) => (