Skip to content

Commit 245b9b7

Browse files
committed
refactor: use React useId() hook for filter component IDs
1 parent 9a5bd05 commit 245b9b7

File tree

9 files changed

+30
-22
lines changed

9 files changed

+30
-22
lines changed

src/renderer/components/filters/ReasonFilter.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { FC } from 'react';
1+
import { type FC, useId } from 'react';
22

33
import { NoteIcon } from '@primer/octicons-react';
44
import { Text } from '@primer/react';
@@ -7,12 +7,14 @@ import { reasonFilter } from '../../utils/notifications/filters';
77
import { FilterSection } from './FilterSection';
88

99
export const ReasonFilter: FC = () => {
10+
const id = useId();
11+
1012
return (
1113
<FilterSection
1214
filter={reasonFilter}
1315
filterSetting="filterReasons"
1416
icon={NoteIcon}
15-
id="filter-reasons"
17+
id={id}
1618
title="Reason"
1719
tooltip={<Text>Filter notifications by reason.</Text>}
1820
/>

src/renderer/components/filters/StateFilter.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { FC } from 'react';
1+
import { type FC, useId } from 'react';
22

33
import { IssueOpenedIcon } from '@primer/octicons-react';
44
import { Text } from '@primer/react';
@@ -7,12 +7,14 @@ import { stateFilter } from '../../utils/notifications/filters';
77
import { FilterSection } from './FilterSection';
88

99
export const StateFilter: FC = () => {
10+
const id = useId();
11+
1012
return (
1113
<FilterSection
1214
filter={stateFilter}
1315
filterSetting="filterStates"
1416
icon={IssueOpenedIcon}
15-
id="filter-state"
17+
id={id}
1618
title="State"
1719
tooltip={<Text>Filter notifications by state.</Text>}
1820
/>

src/renderer/components/filters/SubjectTypeFilter.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { FC } from 'react';
1+
import { type FC, useId } from 'react';
22

33
import { BellIcon } from '@primer/octicons-react';
44
import { Text } from '@primer/react';
@@ -7,12 +7,14 @@ import { subjectTypeFilter } from '../../utils/notifications/filters';
77
import { FilterSection } from './FilterSection';
88

99
export const SubjectTypeFilter: FC = () => {
10+
const id = useId();
11+
1012
return (
1113
<FilterSection
1214
filter={subjectTypeFilter}
1315
filterSetting="filterSubjectTypes"
1416
icon={BellIcon}
15-
id="filter-subject-type"
17+
id={id}
1618
title="Type"
1719
tooltip={<Text>Filter notifications by type.</Text>}
1820
/>

src/renderer/components/filters/UserTypeFilter.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { FC } from 'react';
1+
import { type FC, useId } from 'react';
22

33
import {
44
DependabotIcon,
@@ -13,12 +13,14 @@ import { userTypeFilter } from '../../utils/notifications/filters';
1313
import { FilterSection } from './FilterSection';
1414

1515
export const UserTypeFilter: FC = () => {
16+
const id = useId();
17+
1618
return (
1719
<FilterSection
1820
filter={userTypeFilter}
1921
filterSetting="filterUserTypes"
2022
icon={FeedPersonIcon}
21-
id="filter-user-types"
23+
id={id}
2224
layout="horizontal"
2325
title="User Type"
2426
tooltip={

src/renderer/components/filters/__snapshots__/ReasonFilter.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/renderer/components/filters/__snapshots__/StateFilter.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/renderer/components/filters/__snapshots__/SubjectTypeFilter.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/renderer/components/filters/__snapshots__/UserTypeFilter.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/renderer/routes/__snapshots__/Filters.test.tsx.snap

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)