Fix slug input (#8888)

* allow arrow keys in slug input

* enable preserveTrailingDash for slug input
This commit is contained in:
Azri Kahar
2021-10-19 00:14:50 +08:00
committed by GitHub
parent c88db66282
commit e3aa9fae2a

View File

@@ -179,7 +179,17 @@ export default defineComponent({
function processValue(event: KeyboardEvent) {
if (!event.key) return;
const key = event.key.toLowerCase();
const systemKeys = ['meta', 'shift', 'alt', 'backspace', 'tab'];
const systemKeys = [
'meta',
'shift',
'alt',
'backspace',
'tab',
'arrowup',
'arrowdown',
'arrowleft',
'arrowright',
];
const value = (event.target as HTMLInputElement).value;
if (props.slug === true) {
@@ -233,7 +243,7 @@ export default defineComponent({
} else {
if (props.slug === true) {
const endsWithSpace = value.endsWith(' ');
value = slugify(value, { separator: props.slugSeparator });
value = slugify(value, { separator: props.slugSeparator, preserveTrailingDash: true });
if (endsWithSpace) value += props.slugSeparator;
}