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][material-ui] Select allows a second selection while closing #38414

Open
2 tasks done
ColinMcCullough opened this issue Aug 10, 2023 · 4 comments
Open
2 tasks done
Assignees
Labels
component: select This is the name of the generic UI component, not the React module! discussion

Comments

@ColinMcCullough
Copy link

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

Link to live example:
Example with a slow transition to illustrate the issue: https://codesandbox.io/s/intelligent-ben-wsfz3w?file=/Demo.tsx:823-921

Steps:

  1. Open the select
  2. Select an option
  3. Click another option while the transition is occurring.
  4. The second options value will be set

Current behavior 😯

When selecting a menu item from the Select components dropdown, a second item can accidentally be selected if the user double clicks.

Expected behavior 🤔

Once a selection is made from the menu, a second selection should not be able to be made.

Context 🔦

Customers are accidentally selecting the wrong option when double clicking.

Your environment 🌎

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.
@ColinMcCullough ColinMcCullough added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 10, 2023
@zannager zannager added the component: select This is the name of the generic UI component, not the React module! label Aug 11, 2023
@michaldudak
Copy link
Member

You can disable pointer event on a closing menu using style overrides:

const theme = createTheme({
  components: {
    MuiMenu: {
      styleOverrides: {
        list: {
          [`.${menuClasses.root}[aria-hidden] &`]: {
            pointerEvents: "none"
          }
        }
      }
    }
  }
});

See https://codesandbox.io/s/naughty-lake-h2sm26?file=/Demo.tsx for the full demo.

Does this help?

@michaldudak michaldudak added discussion and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 11, 2023
@ColinMcCullough
Copy link
Author

You can disable pointer event on a closing menu using style overrides:

const theme = createTheme({
  components: {
    MuiMenu: {
      styleOverrides: {
        list: {
          [`.${menuClasses.root}[aria-hidden] &`]: {
            pointerEvents: "none"
          }
        }
      }
    }
  }
});

See https://codesandbox.io/s/naughty-lake-h2sm26?file=/Demo.tsx for the full demo.

Does this help?

Thanks, this works! Just curious are multiple selections expected behavior for this component?

@michaldudak
Copy link
Member

I doubt that anyone relies on this "feature". We could fix it in the source. Would you be interested in opening a PR?

@gitkrsna
Copy link

@michaldudak can you please assign this issue to me?

@michaldudak michaldudak assigned gitkrsna and unassigned michaldudak Aug 17, 2023
@michaldudak michaldudak changed the title Select Component Allows a Second Selection While Closing [Select][material-ui] Select allows a second selection while closing Aug 17, 2023
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! discussion
Projects
None yet
Development

No branches or pull requests

4 participants