Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix label on roster for loop #846

Merged
merged 3 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

exports[`RosterForLoop > renders the right number of columns 1`] = `
<div>
<label
class="lunatic-label"
for="table"
id="label-table"
>
Ceci est un test
</label>
<table
class="lunatic-table"
id="table-table"
Expand Down Expand Up @@ -77,7 +84,7 @@ exports[`RosterForLoop > renders the right number of columns 1`] = `
<input
class="button-lunatic"
type="button"
value="Ceci est un test"
value="Add row"
/>
<input
class="button-lunatic"
Expand Down
10 changes: 6 additions & 4 deletions src/components/loop/roster-for-loop/roster-for-loop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
DeclarationsBeforeText,
DeclarationsDetachable,
} from '../../declarations';
import { createCustomizableLunaticField, Errors } from '../../commons';
import { createCustomizableLunaticField, Errors, Label } from '../../commons';
import { LoopButton } from '../loop-button';
import D from '../../../i18n';
import type { LunaticComponentProps } from '../../type';
Expand All @@ -30,11 +30,11 @@ export const RosterForLoop = createCustomizableLunaticField<
lines,
handleChange,
declarations,
label,
header,
iterations,
id,
getComponents,
label,
...otherProps // These props will be passed down to the child components
} = props;
const min = lines?.min || DEFAULT_MIN_ROWS;
Expand Down Expand Up @@ -65,9 +65,11 @@ export const RosterForLoop = createCustomizableLunaticField<
}

let cols = 0;

return (
<>
<Label htmlFor={id} id={`label-${id}`}>
{label}
</Label>
<DeclarationsBeforeText declarations={declarations} id={id} />
<DeclarationsAfterText declarations={declarations} id={id} />
<Table id={id}>
Expand Down Expand Up @@ -118,7 +120,7 @@ export const RosterForLoop = createCustomizableLunaticField<
{showButtons && (
<>
<LoopButton onClick={addRow} disabled={nbRows === max}>
{label || D.DEFAULT_BUTTON_ADD}
{D.DEFAULT_BUTTON_ADD}
</LoopButton>
<LoopButton onClick={removeRow} disabled={nbRows === min}>
{D.DEFAULT_BUTTON_REMOVE}
Expand Down
Loading