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 custom component & fix dark-mode background color #224

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
25 changes: 12 additions & 13 deletions src/Suggester.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,7 @@ import { useQuestionId } from "./Question";
import type { SuggesterOptionType } from "@inseefr/lunatic/components/Suggester/SuggesterType";
import TextareaAutosize from "@mui/material/TextareaAutosize";
import { fr } from "@codegouvfr/react-dsfr";
import { Paper, Popper, styled } from "@mui/material";

const CustomPaper = styled(Paper)(() => ({
zIndex: 1,
backgroundColor: "white",
}));

const CustomPopper = styled(Popper)(() => ({
minWidth: "fit-content",
}));
import { useStyles } from "tss-react";

export const Suggester: LunaticSlotComponents["Suggester"] = props => {
const {
Expand All @@ -32,7 +23,16 @@ export const Suggester: LunaticSlotComponents["Suggester"] = props => {
onClear,
disabled,
} = props;

const { css } = useStyles();
const classes = {
paper: css({
zIndex: 1,
left: "0 !important",
}),
popper: css({
minWidth: "fit-content",
}),
};
const id = useId();
const questionId = useQuestionId();
/**
Expand All @@ -46,6 +46,7 @@ export const Suggester: LunaticSlotComponents["Suggester"] = props => {
return (
<Autocomplete
id={id}
classes={classes}
value={(value[0] ?? null) as SuggesterOptionType} //To remove when https://github.com/InseeFr/Lunatic/pull/1067 merged
inputValue={inputValue}
isOptionEqualToValue={(a, b) => a.id === b.id}
Expand Down Expand Up @@ -73,8 +74,6 @@ export const Suggester: LunaticSlotComponents["Suggester"] = props => {
{option.label}
</li>
)}
PaperComponent={({ children }) => <CustomPaper elevation={3}>{children}</CustomPaper>}
PopperComponent={props => <CustomPopper {...props} placement="bottom-start" />}
renderInput={params => {
const errorMessageId = `${params.id}-desc-error`; //we use the same convention as react-dsfr
return (
Expand Down
Loading