Skip to content

Commit

Permalink
Merge pull request #486 from jxzho/master
Browse files Browse the repository at this point in the history
Optimizing the flashing issue when select-option selected.
  • Loading branch information
Tyh2001 authored Jun 14, 2024
2 parents b063e31 + 22abe13 commit ddf33ae
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
13 changes: 10 additions & 3 deletions packages/fighting-design/option/src/option.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
const parentInject: SelectProvide | null = inject(SELECT_PROPS_TOKEN, null)
/** 获取到 trigger 注入的依赖项 */
const triggerInject: TriggerProvide | null = inject(TRIGGER_CLOSE_KEY, null)
/** 获取插槽内容 */
const slotLabel = computed((): string => {
if (!slot.default) {
Expand All @@ -46,10 +46,17 @@
if (!parentInject) {
return false
}
// Trigger 展示状态高优先级
if (!triggerInject?.isVisible()) {
return false
}
// 在过滤属性存在并且是正在输入中,执行过滤操作
if (parentInject.filter && parentInject.isFiltering && currentLabel) {
return currentLabel.toString().includes(parentInject.inputValue)
if (parentInject.filter || parentInject.isFiltering) {
return currentLabel
? currentLabel.toString().includes(parentInject.inputValue)
: false
}
return true
Expand Down
4 changes: 2 additions & 2 deletions packages/fighting-design/select/src/select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@
inputValue,
isFiltering,
onBeforeChange: prop.onBeforeChange,
modelValue: toRef(prop, 'modelValue'),
filter: toRef(prop, 'filter')
modelValue,
filter: prop.filter
})
)
</script>
Expand Down
1 change: 1 addition & 0 deletions packages/fighting-design/trigger/src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export type TriggerChange = (visible: boolean, evt: MouseEvent) => void
*/
export interface TriggerProvide {
close: HandleMouse
isVisible: () => boolean
}
5 changes: 4 additions & 1 deletion packages/fighting-design/trigger/src/trigger.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
*
* 目前仅为了在 dropdown-item 组件中实现点击关闭
*/
provide<TriggerProvide>(TRIGGER_CLOSE_KEY, { close })
provide<TriggerProvide>(TRIGGER_CLOSE_KEY, {
close,
isVisible: () => visible.value
})
// 向外导出关闭方法
defineExpose({ close })
Expand Down

0 comments on commit ddf33ae

Please sign in to comment.