mirror of
https://codeberg.org/MarkusThielker/finances.git
synced 2025-04-12 05:08:43 +00:00
N-FIN-51: add button to clear auto complete input
This commit is contained in:
parent
1b0c5bf6e1
commit
d638196b31
1 changed files with 16 additions and 0 deletions
|
@ -3,6 +3,8 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
|
import { X } from 'lucide-react';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
|
||||||
export interface AutoCompleteInputProps
|
export interface AutoCompleteInputProps
|
||||||
extends React.InputHTMLAttributes<HTMLInputElement> {
|
extends React.InputHTMLAttributes<HTMLInputElement> {
|
||||||
|
@ -80,6 +82,20 @@ const AutoCompleteInput = React.forwardRef<HTMLInputElement, AutoCompleteInputPr
|
||||||
props.onKeyDown?.(e);
|
props.onKeyDown?.(e);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
{
|
||||||
|
value.length > 0 && (
|
||||||
|
<Button
|
||||||
|
className="absolute end-0 top-0 z-10"
|
||||||
|
size="icon"
|
||||||
|
variant="ghost"
|
||||||
|
onClick={() => {
|
||||||
|
handleChange({target: {value: ''}} as any);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<X className="h-4 w-4"/>
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
|
}
|
||||||
{
|
{
|
||||||
open && (
|
open && (
|
||||||
<div
|
<div
|
||||||
|
|
Loading…
Add table
Reference in a new issue