Skip to content

Commit

Permalink
fix: set unique jsx keys
Browse files Browse the repository at this point in the history
Signed-off-by: rare-magma <rare-magma@posteo.eu>
  • Loading branch information
rare-magma committed Dec 9, 2023
1 parent 795c1de commit bad4b5e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 18 deletions.
7 changes: 4 additions & 3 deletions src/components/Budget/BudgetPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,11 @@ export function BudgetPage() {
position={"bottom-center"}
style={{ zIndex: 100 }}
>
{notifications.map((notification) => {
{notifications.map((notification, i) => {
return (
notification && (
<Notification
key={i}
notification={notification}
onShow={() =>
setNotifications(
Expand Down Expand Up @@ -479,12 +480,12 @@ export function BudgetPage() {
)}

{showCards && (
<Container key={`${budget.id}-${needReload}`}>
<Container key={`${budget.id}-${needReload}-cards-container`}>
<Row className="mt-1">
<Col md="6">
<div className="card-columns">
<StatCard
key={budget?.expenses.total + budget?.incomes.total}
key={`${budget?.expenses.total} + ${budget?.incomes.total}-${budget.id}-stat-card`}
onShowGraphs={() => setShowGraphs(true)}
/>

Expand Down
10 changes: 5 additions & 5 deletions src/components/CalculateButton/CalculateButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function CalculateButton({
<>
<OverlayTrigger
trigger="click"
key="top"
key={`${itemForm.id}-${label}-calculate-button-overlay-trigger`}
placement="top"
rootClose={true}
overlay={
Expand All @@ -59,7 +59,7 @@ export function CalculateButton({
<InputGroup
size="sm"
className="mb-1"
key={`${itemForm.id}-operation-group`}
key={`${itemForm.id}-${label}-operation-group`}
>
<Dropdown>
<Dropdown.Toggle
Expand Down Expand Up @@ -103,7 +103,7 @@ export function CalculateButton({
</Dropdown>
<CurrencyInput
id={`${label}-${itemForm.id}-operation-value`}
key={`item-${itemForm.id}-operation-value`}
key={`item-${itemForm.id}-${label}-operation-value`}
className="text-end form-control straight-corners fixed-width-font"
aria-label={`${operation}`}
name="item-operate-value"
Expand All @@ -119,7 +119,7 @@ export function CalculateButton({
/>
<Button
id={`item-${itemForm.id}-trigger-operation-button`}
key={`${itemForm.id}-trigger-operation-button`}
key={`${itemForm.id}-${label}-trigger-operation-button`}
aria-label={"apply change to item value"}
variant="outline-secondary"
type="button"
Expand All @@ -137,7 +137,7 @@ export function CalculateButton({
>
<Button
id={`${label}-${itemForm.id}-operate-button`}
key={`${itemForm.id}-operate-button`}
key={`${itemForm.id}-${label}-operate-button`}
aria-label={"select operation type to item value"}
aria-haspopup="dialog"
variant="outline-secondary"
Expand Down
19 changes: 11 additions & 8 deletions src/components/ItemForm/ItemFormGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,18 @@ export function ItemFormGroup({
}

return (
<InputGroup size="sm" className="mb-1" key={`${itemForm.id}-group`}>
<InputGroup
size="sm"
className="mb-1"
key={`${itemForm.id}-${label}-group`}
>
<OverlayTrigger
delay={250}
placement="top"
overlay={
costPercentage > 0 ? (
<Tooltip
id={`tooltip-value-${itemForm.id}`}
id={`tooltip-value-${label}-${itemForm.id}`}
style={{ position: "fixed" }}
>
{costPercentage}% of revenue
Expand All @@ -92,7 +96,7 @@ export function ItemFormGroup({
<Form.Control
id={`${label}-${itemForm.id}-name`}
aria-label={`item ${itemForm.id} name`}
key={`${itemForm.id}-name`}
key={`${itemForm.id}-${label}-name`}
className="w-25"
ref={inputRef}
defaultValue={itemForm.name}
Expand All @@ -109,7 +113,7 @@ export function ItemFormGroup({
overlay={
costPercentage > 0 ? (
<Tooltip
id={`tooltip-value-${itemForm.id}`}
id={`tooltip-costPercentage-${label}-${itemForm.id}`}
style={{ position: "fixed" }}
>
{costPercentage}% of revenue
Expand All @@ -121,7 +125,7 @@ export function ItemFormGroup({
>
<CurrencyInput
id={`${label}-${itemForm.id}-value`}
key={`${itemForm.id}"-value-${changed}`}
key={`${itemForm.id}-${label}-value-${changed}`}
className="text-end form-control straight-corners fixed-width-font"
aria-label={`item ${itemForm.id} value`}
name="item-value"
Expand All @@ -143,7 +147,6 @@ export function ItemFormGroup({
/>
<OverlayTrigger
trigger="click"
key="top"
placement="top"
rootClose={true}
overlay={
Expand All @@ -164,7 +167,7 @@ export function ItemFormGroup({
<Button
id={`item-${itemForm.id}-delete-confirmation-button`}
aria-label={`confirm item ${itemForm.id} deletion`}
key={`${itemForm.id}-delete-confirmation-button`}
key={`${itemForm.id}-${label}-delete-confirmation-button`}
variant="delete"
type="button"
size="sm"
Expand All @@ -181,7 +184,7 @@ export function ItemFormGroup({
<Button
id={`delete-${label}-${itemForm.id}-button`}
aria-label={`delete item ${itemForm.id}`}
key={`${itemForm.id}-button`}
key={`${itemForm.id}-${label}-delete-button`}
variant="delete"
type="button"
onClick={() => {
Expand Down
1 change: 1 addition & 0 deletions src/components/NavBar/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ export function NavBar({
}
>
<Form.Control
id="budget-name"
aria-label={"budget name"}
key={"budget-name-key-" + budget.id}
defaultValue={budget.name}
Expand Down
3 changes: 2 additions & 1 deletion src/components/StatCard/StatCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ export function StatCard({ onShowGraphs }: StatCardProps) {
</Button>
</OverlayTrigger>
<Form.Control
id="goal-input"
data-testid="goal-input"
className="text-end fixed-width-font"
aria-label={"goal"}
Expand Down Expand Up @@ -336,7 +337,7 @@ export function StatCard({ onShowGraphs }: StatCardProps) {
</OverlayTrigger>
<CurrencyInput
id="reserves"
key={"reserves"}
key={"reserves-input"}
className="text-end form-control fixed-width-font"
aria-label={"reserves"}
name="reserves"
Expand Down
2 changes: 1 addition & 1 deletion src/components/TableCard/TableCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export function TableCard({ header: label }: TableCardProps) {
<Card.Body>
{table?.items?.map((item: ItemForm) => (
<ItemFormGroup
key={`${label}-${item.id}`}
key={`${label}-${item.id}-item-form-group`}
itemForm={item}
label={label}
costPercentage={
Expand Down

0 comments on commit bad4b5e

Please sign in to comment.