Skip to content

Commit

Permalink
Set the select field in OneOfBlock to required based on the `allo…
Browse files Browse the repository at this point in the history
…wEmpty` prop (#2713)

- Replace deprecated `FinalFormSelect` with `SelectField`
- Set the select field in `OneOfBlock` to `required` based on the `allowEmpty` prop
  • Loading branch information
thomasdax98 authored Nov 11, 2024
1 parent 0aeb3b2 commit 8ffc90e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/green-poems-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@comet/blocks-admin": patch
---

Set the select field in `OneOfBlock` to `required` based on the `allowEmpty` prop
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Field, FieldContainer, FinalFormRadio, FinalFormSelect } from "@comet/admin";
import { Box, Divider, FormControlLabel, MenuItem, ToggleButton as MuiToggleButton, ToggleButtonGroup as MuiToggleButtonGroup } from "@mui/material";
import { Field, FieldContainer, FinalFormRadio, SelectField } from "@comet/admin";
import { Box, Divider, FormControlLabel, ToggleButton as MuiToggleButton, ToggleButtonGroup as MuiToggleButtonGroup } from "@mui/material";
import { styled } from "@mui/material/styles";
import isEqual from "lodash.isequal";
import { ReactNode, useCallback } from "react";
Expand Down Expand Up @@ -366,17 +366,7 @@ export const createOneOfBlock = <T extends boolean = boolean>({
{variant === "select" && (
<>
<Box padding={isInPaper ? 3 : 0}>
<Field name="blockType" fullWidth>
{(props) => (
<FinalFormSelect {...props} fullWidth>
{options.map((option) => (
<MenuItem value={option.value} key={option.value}>
{option.label}
</MenuItem>
))}
</FinalFormSelect>
)}
</Field>
<SelectField name="blockType" options={options} fullWidth required={!allowEmpty} />
</Box>
{isInPaper && activeBlock.block && <Divider />}
</>
Expand Down

0 comments on commit 8ffc90e

Please sign in to comment.