-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(AnalyticalTable - TypeScript): adjust column types for filtering (#…
- Loading branch information
Showing
3 changed files
with
34 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 11 additions & 6 deletions
17
packages/main/src/components/AnalyticalTable/defaults/FilterComponent/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,25 @@ | ||
import type { FC } from 'react'; | ||
import { useCallback } from 'react'; | ||
import { stopPropagation } from '../../../../internal/stopPropagation.js'; | ||
import type { InputPropTypes } from '../../../../webComponents/Input/index.js'; | ||
import { Input } from '../../../../webComponents/Input/index.js'; | ||
import type { FilterProps } from '../../types/index.js'; | ||
|
||
export const DefaultFilterComponent: FC<any> = ({ column }) => { | ||
const handleChange = useCallback( | ||
export const DefaultFilterComponent = ({ column }: FilterProps) => { | ||
const handleInput: InputPropTypes['onInput'] = useCallback( | ||
(e) => { | ||
// Setting the filter to `undefined` removes it | ||
column.setFilter(e.target.value || undefined); | ||
}, | ||
[column.setFilter] | ||
); | ||
const handleKeyDown = (e) => { | ||
|
||
const handleKeyDown: InputPropTypes['onKeyDown'] = (e) => { | ||
if (e.key !== 'Enter') { | ||
stopPropagation(e); | ||
} | ||
}; | ||
// todo remove "undefined" check if wc issue has been fixed (https://github.com/SAP/ui5-webcomponents/issues/2616) | ||
return <Input onInput={handleChange} value={column.filterValue ?? ''} showClearIcon onKeyDown={handleKeyDown} />; | ||
|
||
return <Input onInput={handleInput} value={column.filterValue} showClearIcon onKeyDown={handleKeyDown} />; | ||
}; | ||
|
||
DefaultFilterComponent.displayName = 'DefaultFilterComponent'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters