From 06516ec60d48168a79a606c69a428ead6e8395d2 Mon Sep 17 00:00:00 2001
From: tangjinzhou <415800467@qq.com>
Date: Thu, 16 Dec 2021 22:55:28 +0800
Subject: [PATCH] fix: input earch icon
---
components/input/Search.tsx | 7 +++++--
components/input/__tests__/__snapshots__/demo.test.js.snap | 2 +-
.../input/__tests__/__snapshots__/index.test.js.snap | 2 +-
components/tree/__tests__/__snapshots__/demo.test.js.snap | 2 +-
4 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/components/input/Search.tsx b/components/input/Search.tsx
index 620dccb1d..fb8c1ad57 100644
--- a/components/input/Search.tsx
+++ b/components/input/Search.tsx
@@ -71,8 +71,9 @@ export default defineComponent({
suffix = slots.suffix?.(),
...restProps
} = props;
- let { enterButton = slots.enterButton?.() } = props;
+ let { enterButton = slots.enterButton?.() ?? false } = props;
enterButton = enterButton || enterButton === '';
+ const searchIcon = typeof enterButton === 'boolean' ? : null;
const btnClassName = `${prefixCls.value}-button`;
const enterButtonAsElement = Array.isArray(enterButton) ? enterButton[0] : enterButton;
@@ -98,6 +99,7 @@ export default defineComponent({
false,
);
} else {
+ const iconOnly = searchIcon && !enterButton;
button = (
);
}
diff --git a/components/input/__tests__/__snapshots__/demo.test.js.snap b/components/input/__tests__/__snapshots__/demo.test.js.snap
index 3b3feceb7..983896987 100644
--- a/components/input/__tests__/__snapshots__/demo.test.js.snap
+++ b/components/input/__tests__/__snapshots__/demo.test.js.snap
@@ -84,7 +84,7 @@ exports[`renders ./components/input/demo/password-input.vue correctly 1`] = `
¥RMB`;
-exports[`renders ./components/input/demo/search-input.vue correctly 1`] = ``;
+exports[`renders ./components/input/demo/search-input.vue correctly 1`] = ``;
exports[`renders ./components/input/demo/search-input-loading.vue correctly 1`] = ``;
diff --git a/components/input/__tests__/__snapshots__/index.test.js.snap b/components/input/__tests__/__snapshots__/index.test.js.snap
index a44194541..078ed4633 100644
--- a/components/input/__tests__/__snapshots__/index.test.js.snap
+++ b/components/input/__tests__/__snapshots__/index.test.js.snap
@@ -2,7 +2,7 @@
exports[`Input should support maxlength 1`] = ``;
-exports[`Input.Search should support suffix 1`] = `suffix`;
+exports[`Input.Search should support suffix 1`] = `suffix`;
exports[`TextArea should support disabled 1`] = ``;
diff --git a/components/tree/__tests__/__snapshots__/demo.test.js.snap b/components/tree/__tests__/__snapshots__/demo.test.js.snap
index 3e2e7a447..e8e81dd9d 100644
--- a/components/tree/__tests__/__snapshots__/demo.test.js.snap
+++ b/components/tree/__tests__/__snapshots__/demo.test.js.snap
@@ -369,7 +369,7 @@ exports[`renders ./components/tree/demo/replaceFields.vue correctly 1`] = `
`;
exports[`renders ./components/tree/demo/search.vue correctly 1`] = `
-