From 2b16f523b5ec2faed73b90011aaf25c3105cd49c Mon Sep 17 00:00:00 2001 From: melloware Date: Mon, 2 Jan 2023 15:00:29 -0500 Subject: [PATCH] Fix #3885: Chips separator works on mobile --- components/lib/chips/Chips.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/components/lib/chips/Chips.js b/components/lib/chips/Chips.js index f6585c58b1..7bd7690502 100644 --- a/components/lib/chips/Chips.js +++ b/components/lib/chips/Chips.js @@ -82,17 +82,15 @@ export const Chips = React.memo( return; } - switch (event.which) { - //backspace - case 8: + switch (event.code) { + case 'Backspace': if (inputRef.current.value.length === 0 && values.length > 0) { removeItem(event, values.length - 1); } break; - //enter - case 13: + case 'Enter': if (inputValue && inputValue.trim().length && (!props.max || props.max > values.length)) { addItem(event, inputValue, true); } @@ -106,7 +104,7 @@ export const Chips = React.memo( if (isMaxedOut()) { event.preventDefault(); - } else if (props.separator === ',' && event.which === 188) { + } else if (props.separator === ',' && event.code === 'Comma') { addItem(event, inputValue, true); }