Open raesche opened 2 years ago
I couldn't reproduce it on the sandbox you shared ππ» !
@raesche Forked your codesandbox and tried with disabled
You added screenshot which has multiple props true, and you shared the codesandbox link with single selection.
Please atleast share the codesandbox with same scenario which you want to explain.
However I tried and issue is not reproduced - Codesandbox
It doesn't look like this bug report has enough info for one of us to reproduce it.
Please provide a CodeSandbox (https://material-ui.com/r/issue-template-latest), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem.
Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve
Since the issue is missing key information and has been inactive for 7 days, it has been automatically closed. If you wish to see the issue reopened, please provide the missing information.
I was unable to reproduce this issue on any sandbox, that's why I could not provide a sandbox link with the problem. However the problem still exists in my project (it's an electron application) and I was not able to resolve it (even when copying the sample code from the MUI website and updating to the latest version).
In the meantime I discovered that the spurious element is the label that is somehow not properly hidden. My workaround inside my React component looks as follows:
const inputRef = useRef();
useEffect(() => {
if (inputRef.current) {
const inputElement = [...inputRef.current.children].find(node => node.nodeName === "INPUT");
if (inputElement)
inputElement.style.display = "none";
}
}, [inputRef]);
...
<Select
ref={inputRef}
....
>
Why don't you ignore setting the display style of the input and instead show the input element when needed using conditional rendering.
Example:
const [someState, setState] = useState(false);
return (
<div>
{someState && <input />}
</div>
);
If you need some help with your project, email me! I will help you figure out what the problem is.
Dear Haneen
Thanks, but the issue is not related to a single \ that needs to be visible or hidden. The problematic \ is part of the \
Searching the problematic \ within the \
Pretty sure it's a CSS overwrite issue. Check your global CSS, you might have input:disabled
with opacity > 0 somewhere.
Thanks minh-le-jh for your reply. The project is already old and uses my workaround, but I will give it a try next time I'm working on on it.
Best regards
Duplicates
Latest version
Current behavior π―
In my project, the Select component shows spurious elements when its 'disabled' property is set. The problem only arises when the 'multiple' attribute is also set. The spurious elements that are visible correspond to the selected values and should be invisible.
I'm using the latest mui version (mui-material 5.9.0, emotion 11.9.3) inside an electron application (chrome browser).
This is the select with 'disabled' not set
This is the select with 'disabled' set
Expected behavior π€
The
The screenshot above was made from an online sandbox that works as expected: https://codesandbox.io/s/selectvariants-demo-material-ui-forked-yjetry?file=/demo.js
Steps to reproduce πΉ
Steps:
Context π¦
No response
Your environment π