mui / mui/material-ui

Suppress the material UI Select component out of range error

Open
#28,307 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

scope: select type: new feature
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

  • I have searched the issues of this repository and believe that this is not a duplicate.

Summary 💡

When creating a Select field that is managed and the values are not yet loaded, the following error pops up:

Material-UI: You have provided an out-of-range value `NL` for the select component.
Consider providing a value that matches one of the available options or ''.
The available values are "".

This error is hard to get rid of and should be able to be suppressed?

While the error could be prevented by not showing the Select component while anything is still loading. This kind of beats the idea of modern web pages, to show data as soon as possible.

For example, a user page can show the current selected country, while still loading the list of countries.

The error should be suppressible/ignorable as not to clutter the log with long error message.

Examples 🌈

export const ChangeCountryView = function ChangeCountryView(props:)  {
    const {user}  = props
    
    const [mainList, setMainList] = React.useState<string[]>([]);
    React.useEffect(() => {
        someLoader.loadCountryListFromServer().then((loadedList) => {
            setMainList(loadedList);
        });
    }, []);
    return <Select value={user.country}>{
        Array.from(mainList, (v) => {
            return <MenuItem key={v} value={v}>{v}</MenuItem>
        });
    }</Select>
}

Motivation 🔦

To enable progressive loaded pages this would really help, while actually improving the tools to bug fix actual bugs.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Select component and reproduce the out-of-range warning with a controlled value whose options load asynchronously. Determine how the warning can be suppressed or ignored, then verify that the warning remains available for actual invalid values and that the documented example behavior is covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.