Skip to content

Commit

Permalink
Fix ListFilter and DateTime adornment errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelo Statescu committed Nov 6, 2023
1 parent d813a71 commit d4c406f
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 47 deletions.
32 changes: 20 additions & 12 deletions src/components/inputs/DateTime/DateTime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,29 @@ const DateTime: React.FC<DateTimeProps> = ({
required={required}
error={error}
helperText={helperText}
InputProps={{
endAdornment: (
<DateTimeEndAdornment
isClearable={internalIsClearable}
onClear={handleClear}
onOpen={handleOpen}
OpenPickerIcon={OpenPickerIcon}
disabled={disabled}
/>
)
}}
endAdornment={
<DateTimeEndAdornment
isClearable={internalIsClearable}
onClear={handleClear}
onOpen={handleOpen}
OpenPickerIcon={OpenPickerIcon}
disabled={disabled}
/>
}
/>
)
},
[disabled, error, handleClear, handleOpen, helperText, inputProps, required, internalIsClearable, mergedComponents.OpenPickerIcon]
[
disabled,
error,
handleClear,
handleOpen,
helperText,
inputProps,
required,
internalIsClearable,
mergedComponents.OpenPickerIcon
]
)

const localeUsed = useMemo(() => localeMap[format] ?? adapterLocale ?? localeMap.ro, [format, adapterLocale])
Expand Down
5 changes: 2 additions & 3 deletions src/components/inputs/DateTime/DateTimeEndAdornment.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React from 'react'
import PropTypes from 'prop-types'
import InputAdornment from '@mui/material/InputAdornment'
import { ClearSmallIcon, IconButton } from './DateTimeStyles'
import { DateTimeEndAdornmentProps } from './types'

const DateTimeEndAdornment = ({ isClearable, onClear, onOpen, OpenPickerIcon, disabled }: DateTimeEndAdornmentProps) => {
return (
<InputAdornment position="end">
<>
{isClearable && (
<IconButton onClick={onClear} disabled={disabled} aria-label="Clear">
<ClearSmallIcon />
Expand All @@ -15,7 +14,7 @@ const DateTimeEndAdornment = ({ isClearable, onClear, onOpen, OpenPickerIcon, di
<IconButton onClick={onOpen} disabled={disabled} aria-label="Open">
<OpenPickerIcon />
</IconButton>
</InputAdornment>
</>
)
}

Expand Down
56 changes: 43 additions & 13 deletions src/components/inputs/ListFilter/FullTextFilterEndAdornment.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,53 @@
import React from 'react'
import PropTypes from 'prop-types'
import InputAdornment from '@mui/material/InputAdornment'
import { FullTextFilterEndAdornmentProps } from './types'
import FilterListIcon from '@mui/icons-material/FilterList'
import { IconButton } from '../../../components'

const FullTextFilterEndAdornment = ({ localizedStrings, resetTextFilter, expandFilters, expanded, openVisibleFiltersMenu, hasChildren, hasVisibleFilters } : FullTextFilterEndAdornmentProps) => {
const FullTextFilterEndAdornment = ({
localizedStrings,
resetTextFilter,
expandFilters,
expanded,
openVisibleFiltersMenu,
hasChildren,
hasVisibleFilters
}: FullTextFilterEndAdornmentProps) => {
return (
<InputAdornment position="end">
<IconButton size='small' type='cancel' color='transparent' aria-label='Reset Filters' aria-description={localizedStrings.ResetFilters} tooltip={localizedStrings.ResetFilters} onClick={resetTextFilter} />
{hasChildren && (
<IconButton size='small' type={expanded ? 'expandLess': 'expandMore'} color='transparent' aria-label='Show Filters' aria-description={localizedStrings.ShowFilters} tooltip={localizedStrings.ShowFilters} onClick={expandFilters} />
)}
{hasChildren && expanded && hasVisibleFilters && (
<IconButton size='small' color='transparent' aria-label='Visible Filters' aria-description={localizedStrings.ChooseFilters} tooltip={localizedStrings.ChooseFilters} onClick={openVisibleFiltersMenu}>
<FilterListIcon/>
</IconButton>
)}
</InputAdornment>
<>
<IconButton
size="small"
type="cancel"
color="transparent"
aria-label="Reset Filters"
aria-description={localizedStrings.ResetFilters}
tooltip={localizedStrings.ResetFilters}
onClick={resetTextFilter}
/>
{hasChildren && (
<IconButton
size="small"
type={expanded ? 'expandLess' : 'expandMore'}
color="transparent"
aria-label="Show Filters"
aria-description={localizedStrings.ShowFilters}
tooltip={localizedStrings.ShowFilters}
onClick={expandFilters}
/>
)}
{hasChildren && expanded && hasVisibleFilters && (
<IconButton
size="small"
color="transparent"
aria-label="Visible Filters"
aria-description={localizedStrings.ChooseFilters}
tooltip={localizedStrings.ChooseFilters}
onClick={openVisibleFiltersMenu}
>
<FilterListIcon />
</IconButton>
)}
</>
)
}

Expand Down
32 changes: 13 additions & 19 deletions src/components/inputs/ListFilter/ListFilter.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback, useMemo, useState } from 'react'
import PropTypes from 'prop-types'
import { TextField, Autocomplete, Button, Dialog } from '../../../components'
import { Toolbar, Collapse, Menu, MenuItem, InputAdornment, Grid } from '@mui/material'
import { Toolbar, Collapse, Menu, MenuItem, Grid } from '@mui/material'
import SearchIcon from '@mui/icons-material/Search'
import { ListFilterProps, UserPreference } from './types'
import UserPreferencesModalContent from './UserPreferencesModalContent'
Expand Down Expand Up @@ -224,24 +224,18 @@ const ListFilter: React.FC<ListFilterProps> = ({
maxLength: searchTextMaxLength,
placeholder: searchPlaceholder
}}
InputProps={{
startAdornment: (
<InputAdornment position="start">
<SearchIcon />
</InputAdornment>
),
endAdornment: (
<FullTextFilterEndAdornment
localizedStrings={localizedStrings}
resetTextFilter={resetTextFilter}
expandFilters={expandFilters}
expanded={expanded}
openVisibleFiltersMenu={openVisibleFiltersMenu}
hasChildren={hasChildren}
hasVisibleFilters={hasVisibleFilters}
/>
)
}}
startAdornment={<SearchIcon />}
endAdornment={
<FullTextFilterEndAdornment
localizedStrings={localizedStrings}
resetTextFilter={resetTextFilter}
expandFilters={expandFilters}
expanded={expanded}
openVisibleFiltersMenu={openVisibleFiltersMenu}
hasChildren={hasChildren}
hasVisibleFilters={hasVisibleFilters}
/>
}
/>
</Grid>
)}
Expand Down

0 comments on commit d4c406f

Please sign in to comment.