Reacting to the dynamic removal of spaces

Is there a way to dynamically remove the space between removed chips and older chips in Material-UI when deleting one of them?

                        <div className="row contactsContainer">
                            {contacts.map((contact) => (
                                <div className="col-lg-1 col-md-3 col-sm-4 col-xs-6 my-5">
                                    <Chip
                                    id={contact!.phone}
                                    label="delete"
                                    variant="outlined"
                                    color="primary"
                                    deleteIcon={
                                        <HighlightOffOutlinedIcon id={`del-${contact!.phone}`} />
                                    }
                                    onDelete={handeldelete}
                                    avatar={
                                        <Avatar
                                            alt={`${contact ? contact.phone : ""}`}
                                            src={lady}
                                            className={`li-avatar ${contact ? "" : "d-none"}`}
                                            title={contact?.phone}
                                        />
                                    }
                                    />
                                </div>
                            ))}
                            <div className="col-lg-1 col-md-3 col-sm-4 col-xs-6 my-5 ">
                            {/* <Chip
                                    id="addContact"
                                    label="delete"
                                    avatar={
                                        <Avatar
                                            alt="add contact"
                                            src={add_image}
                                            className={`li-avatar`}
                                            title="Add New Contact"
                                        />
                                    }
                                    /> */}
                                    <div>
                                <a onClick={handleClickOpen}>
                                    <img src={add_image} alt="add_image" className="circle_image" />
                                </a> 
                                </div>
                            </div>
                        </div>

Any suggestions on how to achieve this? Can I accomplish this using Material-UI instead of Bootstrap as shown in this example?

Answer №1

I am confident that the solution will work as expected. Could you kindly provide the code for the function used to eliminate the Chip? My understanding is that removing the item should also remove any associated spaces. Perhaps a more detailed explanation of your issue would help clarify things?

Check out this demonstration using material-ui to see how chips can be removed from an array:

Explore the chip removal example on CodeSandbox

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

When using tsdx with React, null values can prevent proper usage of hooks

Recently, I attempted to develop a React TypeScript component using tsdx for compilation and encountered a roadblock while debugging. The package appears to be successfully published and installed without any errors. However, when trying to use it, I consi ...

Animating CSS when closing a modal box

I followed the instructions from a tutorial on W3Schools here to create this code. The "open model" button triggers the modal to open with a smooth CSS animation, which looks great. However, when I click the close button, the modal abruptly closes without ...

Safari not updating Angular ng-style properly

I created a simple carousel using Angular and CSS animations which works well in Chrome. However, I recently tested it in Safari and noticed that the click and drag functionality does not work. I've been trying to fix this issue for days and could use ...

Are the frameworks Vue, Angular, and React known for

During a conversation, I came across an interesting viewpoint criticizing popular frameworks such as Angular, Vue, and React. It was argued that these frameworks have a significant disadvantage: apart from the API part that interacts with the server's ...

Height Miscalculation: Chrome and FF encounter window dimension

There is a large application with numerous pages. When I use the console to execute console.log($(window).height()) on any page within the application, it returns the expected result: the height of the window, not the document. For instance: $(window).he ...

Angular Material Rotate Ink Bar to Vertical Orientation

After wanting to change the orientation of Angular Material's Tab Component to vertical, I visited this page (Tabs) and experimented with the CSS. By making the necessary adjustments, I successfully displayed the tabs vertically using the following CS ...

How to determine the presence of 'document' in Typecsript and NextJS

Incorporating NextJS means some server-side code rendering, which I can manage. However, I'm facing a challenge when trying to check for set cookies. I attempted: !!document && !!document.cookie as well as document !== undefined && ...

Don't forget to keep track of when the user has closed

How can I ensure that the cache retains the user's action of closing the div? Currently, when I close the div and refresh the page, it reverts back to its original state. Is there a way to make this change persistent? Experience it live: Here is the ...

Can a HTML div be created with an animation and a hover-scale effect added to it?

I experimented with using divs as clickable buttons that direct to another page on my website. I added animations to make them rotate into view when the site is loaded. Now, I'm trying to implement a hover effect that will scale the buttons when hover ...

I encountered an issue with route handlers in Next.js version 13.2. Sadly, they are not

I am trying to implement an API on my website with the endpoint /api/popular-movie. Here is an overview of my file structure: https://i.stack.imgur.com/e8Pf8.png Additionally, this is my route.ts code: import { NextResponse } from "next/server"; ...

What is the best way to overlay an input form component on a ReactMapGL component?

I've recently started diving into the world of React app development. My current project involves creating a react app that utilizes the ReactMapGL class from the react-map-gl library to render a map (which I implemented in a Map component). One of my ...

Currently, I am compiling a list of tasks that need to be completed, but I am encountering a dilemma that is proving difficult to resolve

Recently delved into the world of Javascript and encountered a roadblock that I can't seem to overcome. Here's the snippet of code causing me trouble: add = document.getElementById("add"); add.addEventListener("click", () => { console.log("Ple ...

The ion-input border seems to be fluctuating as the keyboard appears on the screen

I'm currently working with Ionic 3 and experiencing an issue where the selected ion-input's border in the ion-content is shifting when the device keyboard appears on the screen. Here is a visual representation of the problem: https://i.stack.imgu ...

Refactoring TypeScript components in Angular

How can I streamline the TypeScript in this component to avoid repeating code for each coverage line? This angular component utilizes an ngFor in the HTML template, displaying a different "GroupsView" based on the context. <div *ngFor="let benefitG ...

Position a component in relation to another component using AngularJS

Utilizing ng-show and ng-hide, I created a descriptive box that appears below text when clicked. However, there is an issue as the description box does not align directly under the text, similar to what is shown in this image https://i.stack.imgur.com/phBh ...

The marriage of a sticky and floating navigation bar using the power of Bootstrap 4

I am currently designing a navigation bar inspired by the layout on the EA GAMES website. While it functions perfectly in Chrome, I am encountering significant display issues in Internet Explorer. Any suggestions on how to troubleshoot and resolve this pro ...

Run the useEffect Hook Only on Component Mount in React

After updating a shopping cart application to CRA 3, which includes eslint-plugin-react-hooks useEffect, I encountered an issue where dependencies are now required in the second parameter array of useEffect. Previously, I had used [] to run only on mount ...

Issue: ReactJS - $npm_package_version variable not functioning properly in build versionIn the current

After trying this suggested solution, unfortunately, it did not work for my specific case. The React application I am working on was initialized with CRA version 5.0.1 and currently has a version of 18.2.0. Additionally, the dotenv version being used is 1 ...

Submit a pdf file created with html2pdf to an S3 bucket using form data

Currently, I have the following script: exportPDF(id) { const options = { filename: 'INV' + id + '.pdf', image: { type: 'jpeg', quality: 0.98 }, html2canvas: { scale: 2, dpi: 300, letterRendering: true, useC ...

Guide to switching between 3 classes with mouseover using JavaScript

Currently, I am dealing with an unordered list that contains 4 items. The goal is to have the list grow to 100% of its width when hovered over, while all 'noun hovered li' items should shrink to a width of 0%. Once the cursor leaves, everything s ...