Skip to content

Commit

Permalink
Fixed Multiselect and Dropdown backspace keyboard event, Added classN…
Browse files Browse the repository at this point in the history
…ame props for Input UI component
  • Loading branch information
miksrv committed Nov 7, 2024
1 parent 32c7f47 commit de861b9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Added additional UI tests for Dropdown, Input and MultiSelect
- Added className props for Input UI component
- Fixed SVG arrow icon color for MultiSelect and Dropdown
- Fixed Multiselect and Dropdown backspace keyboard event

## 1.3.0

Expand Down
4 changes: 4 additions & 0 deletions src/components/dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ const Dropdown = <T,>({
}

if ((event.key === 'Backspace' || event.key === 'Delete') && selectedOption?.key) {
if (search !== '') {
return
}

setSearch(selectedOption?.value)
setSelectedOption(undefined)
onSelect?.(undefined)
Expand Down
5 changes: 4 additions & 1 deletion src/components/input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ import styles from './styles.module.sass'
* InputProps interface, representing the properties for the Input component.
*/
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
/** Additional class names for custom styling */
className?: string
/** Label text displayed above the input field */
label?: string
/** Error message displayed below the input field when an error occurs */
error?: string
}

const Input: React.FC<InputProps> = ({ label, error, ...props }) => (
const Input: React.FC<InputProps> = ({ className, label, error, ...props }) => (
<div
className={cn(
className,
styles.inputContainer,
error && styles.error,
props.required && styles.required,
Expand Down
4 changes: 4 additions & 0 deletions src/components/multiselect/MultiSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ const MultiSelect = <T,>({
}

if (event.key === 'Backspace' || event.key === 'Delete') {
if (search !== '') {
return
}

const selected = [...(selectedOption || [])]

selected.pop()
Expand Down

0 comments on commit de861b9

Please sign in to comment.