Attempting to eliminate the padding from the unordered list (ul) element within the pop-up box

  • Upon clicking the chip with chipName="button test IPA", a popup window appears.
  • I am attempting to remove the padding from the ul tag within that popup.
  • The issue I'm facing is that I cannot locate the ul tag in my HTML or JSX code.
  • I have assigned a className in the React code, but still unable to target it.
  • Could you please assist me so I can learn how to fix this myself in the future?
  • Providing the relevant code snippet below:

https://codesandbox.io/s/qqqk23x3q

tab-demo.js

<td>
                    <ChipsButton
                      className={classes.chipContainer}
                      chipName="button test IPA"

                      // menuItems={IPAMenuItems}
                      //ChipsButton
                    />
                  </td>

              **chips-dialog.js**

                  <Menu
          className={classes.chipButtonContainer}
          id="simple-menu"
          // anchorEl={anchorEl}
          open={open}
          onClose={this.handleClose}
        >
          <MenuItem className={classes.chipButtonContainerHeader}>
            {this.state.menuText}
          </MenuItem>

          <Button
            className={classes.chipButtonContainerButton}
            key={1}
            style={{
              backgroundColor:
                this.state.menuText === "Active selected" ? "green" : ""
            }}
            // style={{ display: this.state.display ? "none" : "" }}
            // aria-owns={anchorEl ? 'simple-menu' : undefined}
            aria-haspopup="true"
            value={"Active"}
            onClick={this.handleSelect}
          >
            Active
          </Button>
          <Button
            key={2}
            style={{
              backgroundColor:
                this.state.menuText === "Inactive selected" ? "green" : ""
            }}
            value={"Inactive"}
            // style={{ display: this.state.display ? "none" : "" }}
            // aria-owns={anchorEl ? 'simple-menu' : undefined}
            aria-haspopup="true"
            onClick={this.handleSelect}
          >
            Inactive
          </Button>
        </Menu>


        const styles = theme => ({
  chipButtonContainer: {
    border: "1px solid brown",
    padding: "0"
  },
  chipButtonContainerHeader: {
    backgroundColor: "green",
    border: "1px solid pink"
  },
  chipButtonContainerButton: {
    border: "1px solid black"
  }
})

;

Answer №1

Pass the MenuListProps down to the List component (MenuList including this) in order to deactivate the padding that is applied to it.

This adjustment can be implemented in the file chips-dialog.js

<Menu
   className={classes.chipButtonContainer}
   //...
   MenuListProps={{ disablePadding: true }}
   onClose={this.handleClose}
>
<!--...-->
</Menu>

Answer №2

Functions in the same way for the <Select> element with MenuProps

<Select
    multiple
    input={<Input />}
    MenuProps={{
      MenuListProps: {
        disablePadding: true
    }}>
    {employees.map((employee) => (
    <MenuItem key={employee.id} value={employee.id}>
        {employee.name}
    </MenuItem>
    ))}
</Select>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing Typescript for Efficient Autocomplete in React with Google's API

Struggling to align the types between a Google address autocomplete and a React-Bootstrap form, specifically for the ref. class ProfileForm extends React.Component<PropsFromRedux, ProfileFormState> { private myRef = React.createRef<FormContro ...

Adjust the Container's gutters in MaterialUI according to screen sizes

I am trying to adjust the gutters for different screen sizes in my project. I want to turn off the gutters for xs, sm, and md, but have them enabled at xl and larger. Despite following the API documentation, it doesn't seem to be working as expected. ...

Error encountered in Vue code, lacks default export on Editor Terminal

I'm not experiencing any issues in the browser, I am getting the desired output. However, why does this keep showing up in the editor terminal? Any assistance would be greatly appreciated. Error - No Default Export: The module "/vue3/src/components/ ...

Responsive columns and fluid Flex row implemented in Bootstrap 4

I am striving to optimize this section for responsiveness. It looks fantastic on larger viewports, but as we start shrinking down, for instance, on a viewport around 930px, I'm facing difficulty in keeping the image perfectly aligned as shown in the i ...

Traversing snapshots

My current setup involves using fancyBox, where images are wrapped in <a> tags to allow for enlargement upon clicking. However, I am facing an issue where users can navigate not only within the same panel but also between panels. Ideally, I want to l ...

Attempting to send JSX as a prop value

IMPORTANT UPDATE: Good news - the code is actually functioning correctly! The issue was caused by a header element obstructing the content, leading to confusion. Apologies for any misunderstandings! I am attempting to pass a simple <p> JSX tag as a ...

Adding an Item to the Cart in React.js

Currently, I am delving into react.js and endeavoring to incorporate a fundamental add to cart feature. My aim is to maintain simplicity in order to grasp the entire process. The setup involves two cards - one showcasing the items and another where the sel ...

Tips for implementing automatic line wrapping in a PDF document using React-PDF

I am experiencing an issue with a PDF rendering where very long words are not wrapping onto a new line, instead overflowing the container and disappearing off the page. Below is the setup causing this problem. The styles are listed followed by the actual ...

Obtaining a return value from a function that involves a series of chained Ajax requests in jQuery

I'm facing an issue with my function that involves chained Ajax requests. Function A and B are both Ajax requests, where A runs first and B runs after A returns its data. The problem arises when Function C executes Function B. Upon execution of Funct ...

Split the page in half with a background image on one side and text on the other

Is there a way to split the page vertically, with a background image on one side and text on the other? I've been struggling to achieve this layout - the background image won't stay on the left while the text remains on the right. Can someone off ...

Assist with JavaScript Programming

Can someone assist me in creating functionality for the "Show Picture" button to toggle the visibility of the picture when clicked? I've been trying to achieve this using an If/Else statement for a school project but have been struggling with it. Any ...

Using Vue.js to dynamically append router links with JavaScript

let link = `<router-link :to="{name : 'profile' , params : { slug : ${response.data.nickname} }}"> <img src="${response.data.avatar}" class="card__image"> </router-link>`; $('body').appen ...

Unable to substitute a value using the useState hook in React

Whenever I click a key, I attempt to update the value of a variable but it appears not to be working as intended. ↓ The current implementation is not effective and needs improvement import React, { useState, useEffect } from 'react'; const Li ...

Tips for using jQuery to add several image source URLs to an array

My JavaScript code uses jQuery to collect all image sources on document load and store them in an array: var sliderImg = []; sliderImg.push($('.thumbnail').children('img').attr('src')); Then, I have a click event set up to a ...

I'm encountering an issue in JavaScript while attempting to convert the following string into a JSON object. Can anyone assist in identifying the problem with this string?

How can I correct this string to make it a valid JavaScript JSON object? txt = '{"Categories" : [{"label":"petifores","id":"1"}, {"label":"wedding cake","id":"2"}, {"label":"shapes of cakes","id":"3"}, ...

PHP is returning an empty response during an AJAX request

I am facing an issue with my AJAX request where I am trying to return a simple echo, but for some reason, it's not working this time. Even after stripping down the code to its bare essentials, the response is still blank. Javascript function getUs ...

Tips for identifying selected rows in Material UI DataGrid

Currently, I am in the process of developing a website using React along with Material UI. My main focus right now is to identify which rows are currently selected in my DataGrid. To achieve this, I want to populate an array with the selected rows using t ...

Using the excel.js module in conjunction with node.js to create distinct columns within a header row

I am facing an issue with Excel.js while trying to add a header row to a CSV file. It seems that all the columns in the row are getting merged into one cell instead of staying separate. Does anyone know how to properly separate the columns? https://i.sst ...

Transferring information between functions

I am trying to retrieve the value of my drop-down within the getData function. Although the data displays correctly in the run function, I am unsure of how to pass that data down to the getData() function. <select class="form-co ...

Creating a navigation bar in React using react-scroll

Is anyone able to assist me with resolving the issue I am facing similar to what was discussed in React bootstrap navbar collapse not working? The problem is that although everything seems to be functioning properly, the navbar does not collapse when cli ...