allow delete key in v-input (#10264)

This commit is contained in:
Azri Kahar
2021-12-04 00:11:23 +08:00
committed by GitHub
parent 6a6a525940
commit 2dc4908207

View File

@@ -182,23 +182,13 @@ export default defineComponent({
function processValue(event: KeyboardEvent) {
if (!event.key) return;
const key = event.key.toLowerCase();
const systemKeys = [
'meta',
'shift',
'alt',
'backspace',
'tab',
'arrowup',
'arrowdown',
'arrowleft',
'arrowright',
];
const systemKeys = ['meta', 'shift', 'alt', 'backspace', 'delete', 'tab'];
const value = (event.target as HTMLInputElement).value;
if (props.slug === true) {
const slugSafeCharacters = 'abcdefghijklmnopqrstuvwxyz01234567890-_~ '.split('');
const isAllowed = slugSafeCharacters.includes(key) || systemKeys.includes(key);
const isAllowed = slugSafeCharacters.includes(key) || systemKeys.includes(key) || key.startsWith('arrow');
if (isAllowed === false) {
event.preventDefault();