Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nygrenh committed Mar 19, 2024
1 parent f5534e0 commit da7e03f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { BlockEditProps } from "@wordpress/blocks"
import React from "react"
import { useTranslation } from "react-i18next"

import ErrorBanner from "../../shared-module/components/ErrorBanner"
import CheckBox from "../../shared-module/components/InputFields/CheckBox"
import BlockPlaceholderWrapper from "../BlockPlaceholderWrapper"

Expand Down Expand Up @@ -41,6 +42,9 @@ const ResearchConsentCheckBoxEditor: React.FC<
onChange={(value: string) => setAttributes({ content: value })}
/>
</div>
{(attributes.content ?? "").split(/\s+/).length < 3 && (
<ErrorBanner error={t("error-question-too-short")} variant="readOnly" />
)}
</BlockPlaceholderWrapper>
)
}
Expand Down
8 changes: 6 additions & 2 deletions shared-module/src/components/InputFields/CheckBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,14 @@ const CheckBox = forwardRef<HTMLInputElement, CheckboxProps>(
aria-invalid={rest.error !== undefined}
onChange={handleOnChange}
ref={ref}
dangerouslySetInnerHTML={labelIsRawHtml ? { __html: rest.label } : undefined}
{...rest}
/>
{!labelIsRawHtml && <span>{rest.label}</span>}
{/* eslint-disable-next-line react/no-danger-with-children */}
<span
dangerouslySetInnerHTML={labelIsRawHtml ? { __html: rest.label } : undefined}
// eslint-disable-next-line react/no-children-prop
children={labelIsRawHtml ? undefined : rest.label}
/>
</Label>
{rest.error && (
<span
Expand Down
1 change: 1 addition & 0 deletions shared-module/src/locales/en/cms.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"error": "Error",
"error-cannot-render-editor-for-exercise-service-x": "Cannot render editor for exercise service {{slug}}.",
"error-cannot-render-exercise-task-missing-url": "Cannot render exercise task, missing url.",
"error-question-too-short": "Question is too short.",
"error-spec-not-parseable": "Spec not parseable.",
"exercise-custom-view-block": "Exercise Custom View block",
"exercise-custom-view-block-explanation": "A view to an exercise service that is not related to an exercise.",
Expand Down
1 change: 1 addition & 0 deletions shared-module/src/locales/fi/cms.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"error": "Virhe",
"error-cannot-render-editor-for-exercise-service-x": "En pysty renderöimään editoria tehtäväpalvelulle {{slug}}.",
"error-cannot-render-exercise-task-missing-url": "Harjoitustehtävää ei voi renderöidä, URL-osoite puuttuu.",
"error-question-too-short": "Kysymys on liian lyhyt.",
"error-spec-not-parseable": "Mallivastausta ei voida parsia",
"exercise-custom-view-block": "Mukautettu näkymä lohko",
"exercise-custom-view-block-explanation": "Näkymä tehtäväpalveluun, joka ei liity tehtävään.",
Expand Down

0 comments on commit da7e03f

Please sign in to comment.