Skip to content

Commit

Permalink
fix(comp:select): the onSearch should be called when the intput is cl…
Browse files Browse the repository at this point in the history
…ear (#1577)
  • Loading branch information
danranVm committed Jun 27, 2023
1 parent d8b9aed commit ab4e4b0
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions packages/components/_private/selector/src/Selector.tsx
Expand Up @@ -124,6 +124,7 @@ export default defineComponent({
}
evt.stopPropagation()
callEmit(props.onClear, evt)
mergedSearchable.value && callEmit(props.onSearch, '')
}

provide(selectorToken, {
Expand Down
6 changes: 4 additions & 2 deletions packages/components/cascader/src/Cascader.tsx
Expand Up @@ -96,7 +96,6 @@ export default defineComponent({
selectedStateContext.handleSelect(key)
}
const handleClear = (evt: MouseEvent) => {
evt.stopPropagation()
setValue([])
callEmit(props.onClear, evt)
}
Expand Down Expand Up @@ -157,7 +156,10 @@ export default defineComponent({
setInputValue(value)
props.searchable && callEmit(props.onSearch, value)
}
const handleSearchClear = () => setInputValue('')
const handleSearchClear = () => {
setInputValue('')
props.searchable && callEmit(props.onSearch, '')
}
const renderContent = () => {
const { searchable, overlayRender } = props
const searchValue = inputValue.value
Expand Down
7 changes: 2 additions & 5 deletions packages/components/notification/src/types.ts
Expand Up @@ -10,9 +10,6 @@ import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray, VKey }
import type { ButtonProps } from '@idux/components/button'
import type { DefineComponent, HTMLAttributes, PropType, VNode, VNodeProps } from 'vue'

// 挑出部分必填的属性
type PickRequire<T, U extends keyof T> = Pick<T, Exclude<keyof T, U>> & Required<Pick<T, U>>

export interface NotificationButtonProps<K = VKey> extends ButtonProps {
key?: K
text?: string | VNode
Expand Down Expand Up @@ -69,8 +66,8 @@ export type NotificationComponent = DefineComponent<
export type NotificationInstance = InstanceType<DefineComponent<NotificationProps>>

// 通过useNotification的配置
export interface NotificationOptions<K = VKey> extends PickRequire<NotificationProps, 'title' | 'content'> {
key: K
export interface NotificationOptions<K = VKey> extends NotificationProps {
key?: K
contentProps?: Record<string, unknown> | VNodeProps
onDestroy?: (key: K) => void
}
Expand Down
5 changes: 4 additions & 1 deletion packages/components/select/src/Select.tsx
Expand Up @@ -185,7 +185,10 @@ export default defineComponent({
setInputValue(value)
props.searchable && callEmit(props.onSearch, value)
}
const handleSearchClear = () => setInputValue('')
const handleSearchClear = () => {
setInputValue('')
props.searchable && callEmit(props.onSearch, '')
}

children.unshift(
<div class={`${mergedPrefixCls.value}-overlay-search-wrapper`}>
Expand Down
Expand Up @@ -58,7 +58,6 @@ export function useSelectedState(
}

const handleClear = (evt: MouseEvent) => {
evt.stopPropagation()
setValue([])
callEmit(props.onClear, evt)
}
Expand Down
5 changes: 4 additions & 1 deletion packages/components/tree-select/src/content/Content.tsx
Expand Up @@ -128,7 +128,10 @@ export default defineComponent({
setInputValue(value)
props.searchable && callEmit(props.onSearch, value)
}
const handleClear = () => setInputValue('')
const handleClear = () => {
setInputValue('')
props.searchable && callEmit(props.onSearch, '')
}

return () => {
const {
Expand Down

0 comments on commit ab4e4b0

Please sign in to comment.