Skip to content

Commit

Permalink
Revert "Merge pull request #444 from EfrainAD/Efrain_Fixed_Dropdowns_…
Browse files Browse the repository at this point in the history
…In_Form"

This reverts commit fd61d08, reversing
changes made to ec340dc.
  • Loading branch information
mattdelsordo committed Sep 26, 2023
1 parent 14df3b8 commit 6713617
Showing 1 changed file with 2 additions and 33 deletions.
35 changes: 2 additions & 33 deletions frontend/front/src/components/SurveyComponent/HeatPumpDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ import {
MenuItem,
InputLabel,
} from "@mui/material";
import React, {
useCallback,
useEffect,
useMemo,
useRef,
useState,
} from "react";
import React, { useCallback, useMemo } from "react";

/**
* A radio group to be used with react-hook-form
Expand All @@ -27,19 +21,6 @@ export const HeatPumpDropdown = ({
}) => {
const { field: groupField, formState } = useController({ name, control });

const labelFormRef = useRef(null);
const [_, setResizeTrigger] = useState(0);

useEffect(() => {
const refresh = () => setResizeTrigger((prev) => prev + 1);

refresh();

window.addEventListener("resize", refresh);

return () => window.removeEventListener("resize", refresh);
});

const otherFieldName = `${name}/other`;
const showOtherInput = useMemo(
() =>
Expand All @@ -56,21 +37,9 @@ export const HeatPumpDropdown = ({
(field) => {
return (
<FormControl fullWidth error={!!mainFieldError}>
<InputLabel
id={`${name}-dropdown-label`}
sx={{ whiteSpace: "normal" }}
>
<div ref={labelFormRef} style={{ paddingRight: "20px" }}>
{label}
</div>
</InputLabel>
<InputLabel id={`${name}-dropdown-label`}>{label}</InputLabel>
<Select
label={label}
sx={{
height: labelFormRef.current?.scrollHeight
? `${labelFormRef.current?.scrollHeight + 30}px`
: null,
}}
name={`${name}-dropdown`}
aria-labelledby={`${name}-dropdown-label`}
variant="filled"
Expand Down

0 comments on commit 6713617

Please sign in to comment.