Giter Club home page Giter Club logo

Comments (4)

ZeeshanTamboli avatar ZeeshanTamboli commented on April 28, 2024 1

Duplicate of #36133.

Also related to #19116, #19096.

Preventing bubbling of keyboard event works: https://codesandbox.io/p/sandbox/sweet-moon-hyytgh.

from material-ui.

PunitSoniME avatar PunitSoniME commented on April 28, 2024

@ako-v

Have you tried using Popover instead of menu ?

Check this example with popover and it is working fine - https://codesandbox.io/p/sandbox/charming-architecture-8xmh5m

Is there any specific use case of using menu ?

from material-ui.

ako-v avatar ako-v commented on April 28, 2024

@ako-v

Have you tried using Popover instead of menu ?

Check this example with popover and it is working fine - https://codesandbox.io/p/sandbox/charming-architecture-8xmh5m

Is there any specific use case of using menu ?

Thanks for reply, but the sandbox is not found!
I checked using the popover and it works fine.

from material-ui.

PunitSoniME avatar PunitSoniME commented on April 28, 2024

@ako-v damn...

My codesandbox account reached at maximum sharable links.

import { useState } from "react";
import Autocomplete from "@mui/material/Autocomplete";
import TextField from "@mui/material/TextField";
import Button from "@mui/material/Button";
import Popover from "@mui/material/Popover";
import Box from "@mui/material/Box";

import "./styles.css";
import { Typography } from "@mui/material";

export default function App() {
  const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
  const open = Boolean(anchorEl);
  const handleOpen = (event: React.MouseEvent<HTMLButtonElement>) => {
    setAnchorEl(event.currentTarget);
  };
  const handleClose = () => {
    setAnchorEl(null);
  };

  return (
    <div className="App">
      <Box p={1} width={500}>
        <Typography>This one works fine</Typography>
        <Autocomplete
          id="autocomplete-demo"
          options={[
            { label: "Option 1", value: 1 },
            { label: "Moption 2", value: 2 },
            { label: "TOption 3", value: 3 },
            { label: "SOption 4", value: 4 },
            { label: "KOption 5", value: 5 },
            { label: "ROption 6", value: 6 },
            { label: "LOption 7", value: 7 },
            { label: "NOption 8", value: 8 },
            { label: "ZOption 9", value: 9 },
          ]}
          multiple
          renderInput={(params) => (
            <TextField
              {...params}
              label="Multiple values"
              placeholder="Favorites"
            />
          )}
        />
      </Box>
      <Box p={1} mt={2}>
        <Typography>
          Open the dropdown and if you type <strong>m</strong> as the first
          letter, it will close the autocomplete, because it is the first letter
          of the label (Multiple values)
        </Typography>
        <Button onClick={handleOpen}>Open Dropdoewn</Button>
        <Popover
          open={open}
          anchorEl={anchorEl}
          onClose={handleClose}
          anchorOrigin={{
            vertical: "bottom",
            horizontal: "left",
          }}
        >
          <Box padding={1} width={500}>
            <Autocomplete
              id="autocomplete-demo1"
              options={[
                { label: "Option 1", value: 1 },
                { label: "Moption 2", value: 2 },
                { label: "TOption 3", value: 3 },
                { label: "SOption 4", value: 4 },
                { label: "KOption 5", value: 5 },
                { label: "ROption 6", value: 6 },
                { label: "LOption 7", value: 7 },
                { label: "NOption 8", value: 8 },
                { label: "ZOption 9", value: 9 },
              ]}
              multiple
              renderInput={(params) => (
                <TextField
                  {...params}
                  label="Multiple values"
                  placeholder="Favorites"
                />
              )}
            />
          </Box>
        </Popover>
      </Box>
    </div>
  );
}

from material-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.