question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Select] Recent removal of `.MuiSelect-root` class prevents specifically targeting root for only `Select`

See original GitHub issue

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

Following the merge of this PR into version 5.1.1, we can no longer specifically target the root element of a Select explicitly without also targeting all Inputs. Having this root class for example allowed you to be able to add different padding for a Select component at the root but not for other Inputs.

I understand it was removed as a result of also removing the root override slot because that usage was unclear - however I think we should still keep the class as that is useful for specificity purposes.

Expected behavior 🤔

.MuiSelect-root is still available as a class on the root element but the slot is not available to apply styleOverrides to.

Steps to reproduce 🕹

Before Select root was removed (v5.1.0): codesanbox

After Select root was removed (v5.2.4): codesandbox

If you compare the two you will see that erroneous padding is present on the right side of the select in the “After” option because it is no longer able to target the Select root to override this.

Context 🔦

Without this root class style overrides get very complicated, very quickly if you are trying to apply varying styles to selects vs inputs vs multiline inputs and there are some styles you may not want just on the input element itself, but rather the wrapper (root). This has also broken our Select styles and prevented us from upgrading beyond 5.1.0 unless we do quite a bit of unconventional style hacking to get our theme back to where it was.

Your environment 🌎

`npx @mui/envinfo`
  System:
    OS: macOS 11.6
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 169.88 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.17.6 - ~/.nvm/versions/node/v14.17.6/bin/node
    Yarn: 1.22.15 - /usr/local/bin/yarn
    npm: 6.14.15 - ~/.nvm/versions/node/v14.17.6/bin/npm
  Managers:
    Homebrew: 3.3.7 - /usr/local/bin/brew
    pip3: 21.2.4 - /usr/local/bin/pip3
    RubyGems: 3.0.3 - /usr/bin/gem
  Utilities:
    Make: 3.81 - /usr/bin/make
    GCC: 4.2.1 - /usr/bin/gcc
    Git: 2.30.1 - /usr/bin/git
    Clang: 13.0.0 - /usr/bin/clang
  Servers:
    Apache: 2.4.48 - /usr/sbin/apachectl
  Virtualization:
    Docker: 20.10.11 - /usr/local/bin/docker
  IDEs:
    IntelliJ: 2021.2.2
    Nano: 2.0.6 - /usr/bin/nano
    VSCode: 1.62.3 - /usr/local/bin/code
    Vim: 8.2 - /usr/bin/vim
    Xcode: /undefined - /usr/bin/xcodebuild
  Languages:
    Bash: 3.2.57 - /bin/bash
    Java: 1.8.0_302 - /Users/steven.rathbauer/.sdkman/candidates/java/current/bin/javac
    Perl: 5.30.2 - /usr/bin/perl
    PHP: 7.3.29 - /usr/bin/php
    Python: 2.7.16 - /usr/bin/python
    Python3: 3.9.7 - /usr/local/bin/python3
    Ruby: 2.6.3 - /usr/bin/ruby
  Databases:
    SQLite: 3.32.3 - /usr/bin/sqlite3
  Browsers:
    Firefox Developer Edition: 95.0
    Safari: 15.1
  Monorepos:
    Yarn Workspaces: 1.22.15
    Lerna: 4.0.0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:23
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
israelKusayevcommented, Apr 27, 2022

I strongly think that it’s a very common use case to style them differently

@hbjORbj are there any updates on it?

0reactions
maciej-baruchcommented, Nov 9, 2022

@rathpc The root styleOverride still works in MuiSelect if you need to use it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Select] Recent removal of `.MuiSelect-root` class prevents ...
[Select] Recent removal of .MuiSelect-root class prevents specifically targeting root for only Select #30225. Open. 2 tasks done.
Read more >
Select API - Material UI - MUI
Name Type Default autoWidth bool false children node classes object
Read more >
How to change material UI select border and label
So far I've tried: const styles = theme => ({ root: { display: "flex", flexWrap ...
Read more >
Striking a Balance Between Native and Custom Select Elements
Here's the plan! We're going to build a styled select element. Not just the outside, but the inside too. Total styling control.
Read more >
chakra-react-select - npm
Start using chakra-react-select in your project by running `npm i chakra-react-select` ... The only exception is the root Select components.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found