element-plus / element-plus

🎉 A Vue.js 3 UI Library made by Element team
https://element-plus.org
MIT License
24.67k stars 16.83k forks source link

[Component] [Component] [date-picker] el-date-picker缺少keyup事件监听 #16810

Open huqingchun opened 6 months ago

huqingchun commented 6 months ago

Bug Type: Component

Environment

Reproduction

Related Component

Reproduction Link

Element Plus Playground

Steps to reproduce

<script setup lang="ts">
import { ref, version as vueVersion } from 'vue'
import { version as epVersion } from 'element-plus'
import { ElementPlus } from '@element-plus/icons-vue'

const msgup = ref('')
const msgdown = ref('')
const msgpress = ref('')
const value1 = ref('')
function keyup(ev){
  msgup.value = ev.type
}
function keydown(ev){
  msgdown.value = ev.type
}
function keypress(ev){
  msgpress.value = ev.type
}
</script>

<template>
  <h1>{{ msgup }}</h1>
  <h1>{{ msgdown }}</h1>
  <h1>{{ msgpress }}</h1>
    <el-time-picker v-model="value1" @keyup="keyup($event)" @keydown="keydown($event)"
     @keypress="keypress($event)"
     placeholder="Arbitrary time" />

  <p>
    <el-icon color="var(--el-color-primary)"><ElementPlus /></el-icon>
    Element Plus {{ epVersion }} + Vue {{ vueVersion }}
  </p>
</template>

What is Expected?

正常触发配置的keyup keypress事件函数

What is actually happening?

无法触发配置的keyup keypress事件函数

Additional comments

(empty)

btea commented 6 months ago

Can you describe a specific scenario where you would need them?

trcat commented 1 week ago

我也遇到了这个问题,原因好像就是 time-picker 内部,v-bind="$attrs" 放在了 el-tooltip 身上,所以监听不到

trcat commented 1 week ago

Can you describe a specific scenario where you would need them?

when I want to do a feature like keyboard navgation,I want to stopPropagation

trcat commented 1 week ago

我也遇到了这个问题,原因好像就是 time-picker 内部,v-bind="$attrs" 放在了 el-tooltip 身上,所以监听不到

虽然不能直接再 el-time-picker 上监听,但是可以在其外部包一层 div,然后监听键盘事件

element plus playground