Skip to content

Commit

Permalink
Wrap checkbox in FieldRoot to not inherit editor field
Browse files Browse the repository at this point in the history
  • Loading branch information
katrinewi committed Dec 13, 2024
1 parent 578d74d commit 6b228c2
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 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 @@ -135,7 +140,7 @@ const PreviewImage = ({ id, image, onSelectImage, showCheckbox, translations, lo
<StyledImageMetadata>
<StyledTopRow>
<Text textStyle="title.medium">
{image.title.title.trim() ? image.title.title : (translations.missingTitleFallback ?? `ID: ${image.id}`)}
{image.title.title.trim() ? image.title.title : translations.missingTitleFallback ?? `ID: ${image.id}`}
</Text>
<IconButton
variant="tertiary"
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 6b228c2

Please sign in to comment.