Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/DTableSearchInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ class DtableSearchInput extends Component {
);
};

renderExactMatch = () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Warning] 新插槽缺少契约测试

Why this matters:
ExactMatchIndicator 是供多个业务入口使用的共享组件契约,代码明确支持 React 元素和函数组件两种输入,但本 PR 没有测试。任一分支在后续重构中失效都会导致精确匹配入口在所有调用方消失。

Suggested fix: 在 DTableSearchInput 的组件测试中分别传入元素和函数组件,并断言两者均渲染;同时保留未传入时不渲染的覆盖。

const { components = {} } = this.props;
const { ExactMatchIndicator } = components;
if (React.isValidElement(ExactMatchIndicator)) {
return ExactMatchIndicator;
} else if (isFunction(ExactMatchIndicator)) {
return <ExactMatchIndicator/>;
}
return null;
};

render() {
const { placeholder, autoFocus, className, onKeyDown, disabled, style } = this.props;
const { searchValue } = this.state;
Expand All @@ -106,6 +117,7 @@ class DtableSearchInput extends Component {
style={style}
/>
{this.renderClear()}
{this.renderExactMatch()}
</Fragment>
);
}
Expand Down
Loading