Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(comp:select): the onSearch should be called when the intput is clear #1577

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/components/_private/selector/src/Selector.tsx
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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