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

[Select] Warn for unmatched value #17691

Merged

Conversation

asownder95
Copy link
Contributor

@asownder95 asownder95 commented Oct 3, 2019

Resolves #17568

• Added console warning when the value is not an empty string or does not match any of the Select options.
• Updated unit tests to use "" instead of "none" to remove warnings when running tests.
• Updated DialogSelect demo so that no console warning was produced when the None option was selected.
• Updated the value prop description in Select component API docs to note that empty string will select no options.

@mui-pr-bot
Copy link

mui-pr-bot commented Oct 3, 2019

Details of bundle changes.

Comparing: 9122b60...cd7f4b9

bundle Size Change Size Gzip Change Gzip
@material-ui/core[umd] -- 306 kB -- 87.9 kB
@material-ui/lab -- 144 kB -- 44.9 kB
@material-ui/styles -- 51.8 kB -- 15.6 kB
@material-ui/system -- 15.6 kB -- 4.35 kB
AppBar -- 64.2 kB -- 20 kB
Avatar -- 62.6 kB -- 19.6 kB
Backdrop -- 67.8 kB -- 20.9 kB
Badge -- 65.6 kB -- 20.2 kB
BottomNavigation -- 62.4 kB -- 19.5 kB
BottomNavigationAction -- 75.4 kB -- 23.8 kB
Box -- 70.7 kB -- 21.3 kB
Breadcrumbs -- 68.3 kB -- 21.3 kB
Button -- 79.6 kB -- 24.6 kB
ButtonBase -- 73.9 kB -- 23.1 kB
ButtonGroup -- 64.5 kB -- 20 kB
Card -- 62.9 kB -- 19.6 kB
CardActionArea -- 75 kB -- 23.6 kB
CardActions -- 62 kB -- 19.3 kB
CardContent -- 62 kB -- 19.3 kB
CardHeader -- 65.4 kB -- 20.4 kB
CardMedia -- 62.4 kB -- 19.5 kB
Checkbox -- 81.9 kB -- 25.7 kB
Chip -- 71 kB -- 21.8 kB
CircularProgress -- 64.4 kB -- 20.1 kB
ClickAwayListener -- 3.91 kB -- 1.59 kB
Collapse -- 67.8 kB -- 20.9 kB
colorManipulator -- 3.83 kB -- 1.52 kB
Container -- 63.4 kB -- 19.7 kB
CssBaseline -- 57.6 kB -- 18 kB
Dialog -- 82.5 kB -- 25.6 kB
DialogActions -- 62.1 kB -- 19.4 kB
DialogContent -- 62.2 kB -- 19.4 kB
DialogContentText -- 64.3 kB -- 20.1 kB
DialogTitle -- 64.6 kB -- 20.2 kB
Divider -- 62.6 kB -- 19.6 kB
docs.landing -- 54.3 kB -- 14.3 kB
docs.main -- 599 kB -- 191 kB
Drawer -- 84.4 kB -- 26.1 kB
ExpansionPanel -- 71.1 kB -- 22.1 kB
ExpansionPanelActions -- 62.1 kB -- 19.4 kB
ExpansionPanelDetails -- 61.9 kB -- 19.3 kB
ExpansionPanelSummary -- 78.2 kB -- 24.6 kB
Fab -- 77 kB -- 23.9 kB
Fade -- 23.1 kB -- 8.06 kB
FilledInput -- 73 kB -- 22.6 kB
FormControl -- 64.8 kB -- 20 kB
FormControlLabel -- 65.8 kB -- 20.5 kB
FormGroup -- 62 kB -- 19.3 kB
FormHelperText -- 63.3 kB -- 19.7 kB
FormLabel -- 63.2 kB -- 19.5 kB
Grid -- 65.1 kB -- 20.3 kB
GridList -- 62.5 kB -- 19.5 kB
GridListTile -- 63.9 kB -- 19.9 kB
GridListTileBar -- 63.2 kB -- 19.7 kB
Grow -- 23.7 kB -- 8.18 kB
Hidden -- 66.4 kB -- 20.7 kB
Icon -- 63.1 kB -- 19.6 kB
IconButton -- 76.3 kB -- 23.7 kB
Input -- 72.1 kB -- 22.5 kB
InputAdornment -- 65.4 kB -- 20.5 kB
InputBase -- 70.3 kB -- 22 kB
InputLabel -- 65.1 kB -- 20.2 kB
LinearProgress -- 65.6 kB -- 20.3 kB
Step -- 62.6 kB -- 19.5 kB
@material-ui/core ▲ +6 B (0.00% ) 346 kB ▲ +7 B (+0.01% ) 94.8 kB
Link -- 66.9 kB -- 21.1 kB
List -- 62.4 kB -- 19.3 kB
ListItem -- 76.8 kB -- 24 kB
ListItemAvatar -- 62.1 kB -- 19.4 kB
ListItemIcon -- 62.2 kB -- 19.4 kB
ListItemSecondaryAction -- 62 kB -- 19.3 kB
ListItemText -- 65.2 kB -- 20.4 kB
ListSubheader -- 63 kB -- 19.7 kB
Menu -- 88.4 kB -- 27.6 kB
MenuItem -- 77.8 kB -- 24.3 kB
MenuList -- 66 kB -- 20.6 kB
MobileStepper -- 68 kB -- 21.1 kB
Modal -- 14.4 kB -- 5.03 kB
NativeSelect -- 76.7 kB -- 24.1 kB
NoSsr -- 2.19 kB -- 1.04 kB
OutlinedInput -- 73.8 kB -- 22.9 kB
Paper -- 62.4 kB -- 19.3 kB
Popover -- 82.8 kB -- 25.5 kB
Popper -- 28.4 kB -- 10.2 kB
Portal -- 2.91 kB -- 1.32 kB
Radio -- 82.5 kB -- 25.8 kB
RadioGroup -- 63.3 kB -- 19.7 kB
Rating -- 70.2 kB -- 22.3 kB
RootRef -- 4.7 kB -- 1.78 kB
Skeleton -- 62.5 kB -- 19.5 kB
Slide -- 25.1 kB -- 8.69 kB
Slider -- 75.3 kB -- 23.6 kB
Snackbar -- 77.1 kB -- 24 kB
SnackbarContent -- 66 kB -- 20.6 kB
SpeedDial -- 85.9 kB -- 27 kB
SpeedDialAction -- 115 kB -- 36.4 kB
SpeedDialIcon -- 64.9 kB -- 20.2 kB
StepButton -- 82.3 kB -- 25.8 kB
StepConnector -- 62.7 kB -- 19.6 kB
StepContent -- 68.9 kB -- 21.4 kB
StepIcon -- 64.9 kB -- 20.1 kB
StepLabel -- 68.9 kB -- 21.5 kB
Stepper -- 64.9 kB -- 20.3 kB
styles/createMuiTheme -- 16.2 kB -- 5.78 kB
SvgIcon -- 63.3 kB -- 19.7 kB
SwipeableDrawer -- 90.7 kB -- 28 kB
Switch -- 81.1 kB -- 25.2 kB
Tab -- 76.5 kB -- 24.2 kB
Table -- 62.4 kB -- 19.4 kB
TableBody -- 62.1 kB -- 19.3 kB
TableCell -- 64.4 kB -- 20.1 kB
TableFooter -- 62.1 kB -- 19.3 kB
TableHead -- 62.1 kB -- 19.3 kB
TableRow -- 62.5 kB -- 19.5 kB
TableSortLabel -- 77.5 kB -- 24.4 kB
Tabs -- 85.6 kB -- 27.2 kB
TextareaAutosize -- 5.11 kB -- 2.14 kB
ToggleButton -- 76.3 kB -- 24 kB
ToggleButtonGroup -- 63.5 kB -- 19.8 kB
Toolbar -- 62.3 kB -- 19.4 kB
Tooltip -- 99 kB -- 31.3 kB
TreeItem -- 73.7 kB -- 23.1 kB
Select ▲ +6 B (+0.01% ) 113 kB ▲ +6 B (+0.02% ) 33.5 kB
TextField ▲ +6 B (0.00% ) 121 kB ▲ +6 B (+0.02% ) 35.4 kB
TablePagination ▲ +6 B (0.00% ) 139 kB ▲ +5 B (+0.01% ) 40.6 kB
TreeView -- 65.9 kB -- 20.6 kB
Typography -- 63.9 kB -- 19.9 kB
useMediaQuery -- 2.49 kB -- 1.05 kB
Zoom -- 23.1 kB -- 8.08 kB

Generated by 🚫 dangerJS against cd7f4b9

@oliviertassinari oliviertassinari changed the title Select unmatched value warning [Select] Warn for unmatched value Oct 3, 2019
@oliviertassinari oliviertassinari added component: select This is the name of the generic UI component, not the React module! new feature New feature or request PR: ready to ship and removed component: select This is the name of the generic UI component, not the React module! new feature New feature or request labels Oct 3, 2019
@oliviertassinari oliviertassinari force-pushed the select-unmatched-value-warning branch from 43ccfa4 to cd7f4b9 Compare October 3, 2019 19:32
console.warn = (...args) => {
// Can't use log as karma is not displaying them.
console.info(...args);
throw new Error(...args);
Copy link
Member

@oliviertassinari oliviertassinari Oct 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we have started to use console.warn in the code base, I think that we should throw the tests for them. I could only find the origin of the new warning thanks to this. Turns out, the table pagination tests had unmatching values.

cc @eps1lon

@oliviertassinari oliviertassinari added PR: ready to ship component: select This is the name of the generic UI component, not the React module! new feature New feature or request and removed component: select This is the name of the generic UI component, not the React module! new feature New feature or request labels Oct 3, 2019
@oliviertassinari oliviertassinari merged commit 49128ba into mui:master Oct 4, 2019
@oliviertassinari
Copy link
Member

@asownder95 Well done 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: select This is the name of the generic UI component, not the React module! new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Value for Select which allows to not select any of the options
3 participants