@@ -14,7 +14,11 @@ import { Clear as ClearIcon } from "@mui/icons-material";
1414
1515import { checkedIcon , icon } from "./constants" ;
1616import { filterFalsy , sortOptions } from "../utils" ;
17- import { TAutocompleteCheckboxProps , TRenderOptions } from "../types" ;
17+ import {
18+ TAutocompleteCheckboxProps ,
19+ TColumnType ,
20+ TRenderOptions ,
21+ } from "../types" ;
1822import { CUSTOM_EVENT_CLEAN_AUTOCOMPLETE } from "../constants" ;
1923
2024const AutocompleteCheckboxInner = < T extends Record < string , any > > (
@@ -39,12 +43,15 @@ const AutocompleteCheckboxInner = <T extends Record<string, any>>(
3943
4044 const [ filters , setFilters ] = useState < string [ ] > ( [ ] ) ;
4145 const [ autocompleteOpen , setAutocompleteOpen ] = useState ( false ) ;
46+ const [ columnType , setColumnType ] = useState < TColumnType > ( null ) ;
4247
4348 const autocompleteOptions = useMemo ( ( ) => {
4449 const rowsObject = header ?. getContext ( ) ?. table . getFilteredRowModel ( ) ;
4550
4651 const noFalsyValues = filterFalsy ( options ) ;
4752
53+ setColumnType ( typeof noFalsyValues [ 0 ] ) ;
54+
4855 const uniqueOptions = [
4956 ...new Set ( noFalsyValues . map ( ( option ) => String ( option ) ) ) ,
5057 ] ;
@@ -112,6 +119,7 @@ const AutocompleteCheckboxInner = <T extends Record<string, any>>(
112119 if ( customEvent . detail . message === CUSTOM_EVENT_CLEAN_AUTOCOMPLETE ) {
113120 setFilters ( [ ] ) ;
114121 setAutocompleteOpen ( false ) ;
122+ setColumnType ( null ) ;
115123 }
116124 } ;
117125
@@ -149,9 +157,13 @@ const AutocompleteCheckboxInner = <T extends Record<string, any>>(
149157 const handleApplyFilter = < T extends Record < string , any > > (
150158 header : MRT_Header < T >
151159 ) => {
152- const handlingNumberValue = filters . map ( ( x ) =>
153- Number . isFinite ( + x ) ? Number ( x ) : x
154- ) ;
160+ const handlingNumberValue = filters . map ( ( x ) => {
161+ const isNumber = columnType === "number" ;
162+
163+ if ( isNumber ) return Number ( x ) ;
164+
165+ return x ;
166+ } ) ;
155167
156168 const newFilterValueState =
157169 handlingNumberValue . length > 0 ? handlingNumberValue : undefined ;
0 commit comments