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: Remove input checkbox elements and replace with spans #3167

Merged
merged 4 commits into from
May 17, 2024
Merged
Changes from all 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 @@ -10,16 +10,14 @@ import FormControl from "@mui/material/FormControl";
import { inputLabelClasses } from "@mui/material/InputLabel";
import List from "@mui/material/List";
import ListItem from "@mui/material/ListItem";
import ListItemText from "@mui/material/ListItemText";
import ListSubheader from "@mui/material/ListSubheader";
import { outlinedInputClasses } from "@mui/material/OutlinedInput";
import { styled } from "@mui/material/styles";
import TextField from "@mui/material/TextField";
import Typography from "@mui/material/Typography";
import capitalize from "lodash/capitalize";
import React, { forwardRef, PropsWithChildren, useMemo, useState } from "react";
import React, { forwardRef, PropsWithChildren, useMemo } from "react";
import { borderedFocusStyle } from "theme";
import Checkbox from "ui/shared/Checkbox";

import { FileUploadSlot } from "../FileUpload/Public";
import {
Expand Down Expand Up @@ -52,6 +50,10 @@ const StyledAutocomplete = styled(
Autocomplete<Option, true, true, false, "div">,
)(({ theme }) => ({
marginTop: theme.spacing(2),
// Prevent label from overlapping expand icon
"& > div > label": {
paddingRight: theme.spacing(3),
},
// Vertically center "large" size caret icon
[`& .${autocompleteClasses.endAdornment}`]: {
top: "unset",
Expand Down Expand Up @@ -88,11 +90,36 @@ const StyledTextField = styled(TextField)(({ theme }) => ({
textDecoration: "none",
color: theme.palette.text.primary,
paddingY: 0,
transform: "translate(14px, -22px) scale(0.85)",
transform: "translate(0px, -22px) scale(0.85)",
},
},
}));

const CustomCheckbox = styled("span")(({ theme }) => ({
display: "inline-flex",
flexShrink: 0,
position: "relative",
width: 40,
height: 40,
borderColor: theme.palette.text.primary,
border: "2px solid",
background: "transparent",
marginRight: theme.spacing(1.5),
"&.selected::after": {
content: "''",
position: "absolute",
height: 24,
width: 12,
borderColor: theme.palette.text.primary,
borderBottom: "5px solid",
borderRight: "5px solid",
left: "50%",
top: "42%",
transform: "translate(-50%, -50%) rotate(45deg)",
cursor: "pointer",
},
}));

/**
* Function which returns the Input component used by Autocomplete
*/
Expand All @@ -109,7 +136,7 @@ const renderInput: AutocompleteProps<
...params.InputProps,
notched: false,
}}
label="What does this file show?"
label="What does this file show? (select all that apply)"
/>
);

Expand Down Expand Up @@ -157,14 +184,8 @@ const renderOption: AutocompleteProps<
"div"
>["renderOption"] = (props, option, { selected }) => (
<ListItem {...props}>
<Checkbox
data-testid="select-checkbox"
checked={selected}
inputProps={{
"aria-label": option.name,
}}
/>
<ListItemText sx={{ ml: 2 }}>{option.name}</ListItemText>
<CustomCheckbox aria-hidden="true" className={selected ? "selected" : ""} />
{option.name}
</ListItem>
);

Expand Down
Loading