Skip to content

Commit

Permalink
Fixed bug in group header button.
Browse files Browse the repository at this point in the history
  • Loading branch information
ransome1 committed Mar 23, 2024
1 parent 813894a commit e102200
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/renderer/Grid/DatePickerInline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const DatePickerInline: React.FC<Props> = ({
<Button id={props.id} disabled={disabled} ref={ref} aria-label={ariaLabel} tabIndex={-1}>
<Badge variant="dot" invisible={mustNotify}>
<Chip
onClick={() => handleFilterSelect(type, formattedValue, [date], filters, false)}
onClick={() => handleFilterSelect(type, formattedValue, date, filters, false)}
label={chipText}
data-testid={`datagrid-button-${type}`}
tabIndex={0}
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/Grid/Renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,23 @@ const RendererComponent: React.FC<RendererComponentProps> = memo(({
/>
),
contexts: (value, type) => (
<Button className='contexts' onClick={() => handleButtonClick(type, value, [value])} data-testid={`datagrid-button-${type}`}>
<Button className='contexts' onClick={() => handleButtonClick(type, value, value)} data-testid={`datagrid-button-${type}`}>
{value}
</Button>
),
projects: (value, type) => (
<Button onClick={() => handleButtonClick(type, value, [value])} data-testid={`datagrid-button-${type}`}>
<Button onClick={() => handleButtonClick(type, value, value)} data-testid={`datagrid-button-${type}`}>
{value}
</Button>
),
rec: (value, type) => (
<Button onClick={() => handleButtonClick(type, value, [value])} data-testid={`datagrid-button-${type}`}>
<Button onClick={() => handleButtonClick(type, value, value)} data-testid={`datagrid-button-${type}`}>
<Chip label="rec:" />
{value}
</Button>
),
pm: (value, type) => (
<Button className='pomodoro' onClick={() => handleButtonClick(type, value, [value])} data-testid={`datagrid-button-${type}`}>
<Button className='pomodoro' onClick={() => handleButtonClick(type, value, value)} data-testid={`datagrid-button-${type}`}>
<TomatoIconDuo />
{value}
</Button>
Expand Down
11 changes: 7 additions & 4 deletions src/renderer/Shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ export const handleFilterSelect = (key: string, name: string, values: string | s
const updatedFilters: Filters = { ...filters };
const filterList: Filter[] = updatedFilters[key] || [];

const normalizedValues = typeof values === 'string' ? [values] : values;

const filterIndex = filterList.findIndex((filter: Filter) => {
return Array.isArray(values) && Array.isArray(filter.values) ?
values.every(v => filter.values.includes(v)) :
filter.values === values;
return Array.isArray(normalizedValues) && Array.isArray(filter.values) ?
normalizedValues.every(v => filter.values.includes(v)) :
filter.values === normalizedValues;
});

if (filterIndex !== -1) {
filterList.splice(filterIndex, 1);
} else {
filterList.push({ name, values, exclude });
filterList.push({ name, values: normalizedValues, exclude });
}

updatedFilters[key] = filterList;
Expand All @@ -35,6 +37,7 @@ export const handleFilterSelect = (key: string, name: string, values: string | s
}
};


export const handleLinkClick = (event: MouseEvent, url: string) => {
event.preventDefault();
event.stopPropagation();
Expand Down

0 comments on commit e102200

Please sign in to comment.