Skip to content

Commit

Permalink
fix: empty keyword on enter
Browse files Browse the repository at this point in the history
  • Loading branch information
adii1203 committed May 2, 2024
1 parent 7d0a96e commit 9365bf5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/app/docs/components/input/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ const [inputValue, setInputValue] = useState<string>('')
// Handles adding new keyword on Enter or comma press, and keyword removal on Backspace
const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
if (
event.key === 'Enter' ||
(event.key === ',' && inputValue.trim() !== '')
(event.key === 'Enter' ||
event.key === ',') && inputValue.trim() !== ''
) {
event.preventDefault()
const newKeywords = [...keywords, inputValue.trim()]
Expand Down
4 changes: 2 additions & 2 deletions src/showcase/components/input/TagInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const TagInput: React.FC = () => {
// Handles adding new keyword on Enter or comma press, and keyword removal on Backspace
const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
if (
event.key === 'Enter' ||
(event.key === ',' && inputValue.trim() !== '')
(event.key === 'Enter' || event.key === ',') &&
inputValue.trim() !== ''
) {
event.preventDefault()
const newKeywords = [...keywords, inputValue.trim()]
Expand Down

0 comments on commit 9365bf5

Please sign in to comment.