Skip to content

Commit

Permalink
Merge pull request #2657 from NDLANO/fix-preview-image-meta-image-che…
Browse files Browse the repository at this point in the history
…ckbox

Wrap checkbox in FieldRoot to not inherit editor field
  • Loading branch information
katrinewi authored Dec 13, 2024
2 parents 204c5a6 + 9fbb310 commit d7d9fb8
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions packages/ndla-image-search/src/PreviewImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
Text,
Image,
IconButton,
FieldRoot,
} from "@ndla/primitives";
import { styled } from "@ndla/styled-system/jsx";
import type { IImageMetaInformationV3DTO } from "@ndla/types-backend/image-api";
Expand Down Expand Up @@ -107,6 +108,10 @@ const ActionsWrapper = styled("div", {
},
});

const StyledFieldRoot = styled(FieldRoot, {
base: { alignSelf: "center" },
});

interface Props {
id: string;
image: IImageMetaInformationV3DTO;
Expand Down Expand Up @@ -202,15 +207,17 @@ const PreviewImage = ({ id, image, onSelectImage, showCheckbox, translations, lo
{translations.useImageTitle}
</Button>
{!!showCheckbox && (
<CheckboxRoot checked={saveAsMetaImage} onCheckedChange={() => setSaveAsMetaImage((prev) => !prev)}>
<CheckboxControl>
<CheckboxIndicator asChild>
<CheckLine />
</CheckboxIndicator>
</CheckboxControl>
<CheckboxLabel>{translations.checkboxLabel}</CheckboxLabel>
<CheckboxHiddenInput />
</CheckboxRoot>
<StyledFieldRoot>
<CheckboxRoot checked={saveAsMetaImage} onCheckedChange={() => setSaveAsMetaImage((prev) => !prev)}>
<CheckboxControl>
<CheckboxIndicator asChild>
<CheckLine />
</CheckboxIndicator>
</CheckboxControl>
<CheckboxLabel>{translations.checkboxLabel}</CheckboxLabel>
<CheckboxHiddenInput />
</CheckboxRoot>
</StyledFieldRoot>
)}
</ActionsWrapper>
</ContentWrapper>
Expand Down

0 comments on commit d7d9fb8

Please sign in to comment.