Align items horizontally bootstrap - reactjs

I have a bootstrap grid layout in my web app I want to align all on the same line. For example, when loading in full screen, the cards look as follows:
However, when the page is resized, the cards appear as follows
I need to make them look like the first image regardless of how the page is resized, jut not sure how to go about doing this.
Below is my code:
<div className="d-flex col-sm-6">
<div className="" style={{backgroundColor: 'white', borderRadius: 5, border: '1px solid #EAE8E8'}}>
<div className="row">
<div className="d-flex col-md-8">
<div className="row" style={{paddingTop: 20, paddingBottom: 20, paddingLeft: 40}}>
<h4>
<b>{this.props.restaurant.name}</b>
{this.props.restaurant.dietaryRestrictions.map(function(dietaryRestriction, index) {
return(<div key={index}><span className="badge-sm badge-secondary" style={{color: 'white', backgroundColor: '#DA9550', fontSize: 9}}>{dietaryRestriction}</span> </div>);
})}
</h4>
{this.props.restaurant.description}
<br /><br />
<span className="munchtime pointer"><i className="fas fa-check"></i> <b>Add to Cart</b></span><br /><br />
<b><s>${this.props.restaurant.price}</s></b> <span className="discount"><b>${this.props.restaurant.price * this.props.restaurant.restaurant.discount}</b></span>
</div>
</div>
<div className="d-flex col-md-4">
<img src={this.props.restaurant.images[0]} style={{width: '100%', height: 250, objectFit: 'cover'}} />
</div>
</div>
</div>
</div>

just divide the grid in 5 by 3 manner for all views (xs, sm, md) as container total width is 8.
media queries breakpoints : grid-media-queries
example is below with the
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="d-flex col-md-8">
<div class="" style="background-color: 'white', border-radius: 5, border: '1px solid #EAE8E8'">
<div class="row">
<div class="d-flex col-xs-5 col-sm-5 col-md-5">
<div class="row" style="padding-top: 20, padding-bottom: 20, padding-left: 40">
<h4>
<b> restaurant name</b>
<div key=1><span class="badge-sm badge-secondary" style="color: 'white', background-color: '#DA9550', font-size: 9">dietaryRestriction</span> </div>
</h4>
restaurant description
<br /><br />
<span class="munchtime pointer"><i class="fas fa-check"></i> <b>Add to Cart</b></span><br /><br />
<b><s>$2000</s></b> <span class="discount"><b>20%</b></span>
</div>
</div>
<div class="d-flex col-xs-3 col-sm-3 col-md-3">
<img src='https://picsum.photos/200/300
' style="width: '100%', height: 250, objectFit: 'cover'" />
</div>
</div>
</div>
</div>

In your code, you are using col-md-8 which will work from min-width of 992px. you can replace md with xs, so that it will work for all resolutions.

<div className="d-flex col-sm-6">
<div className="" style={{backgroundColor: 'white', borderRadius: 5, border: '1px solid #EAE8E8'}}>
<div className="row">
<div className="d-flex col-xs-8">
<div className="row" style={{paddingTop: 20, paddingBottom: 20, paddingLeft: 40}}>
<h4>
<b>{this.props.restaurant.name}</b>
{this.props.restaurant.dietaryRestrictions.map(function(dietaryRestriction, index) {
return(<div key={index}><span className="badge-sm badge-secondary" style={{color: 'white', backgroundColor: '#DA9550', fontSize: 9}}>{dietaryRestriction}</span> </div>);
})}
</h4>
{this.props.restaurant.description}
<br /><br />
<span className="munchtime pointer"><i className="fas fa-check"></i> <b>Add to Cart</b></span><br /><br />
<b><s>${this.props.restaurant.price}</s></b> <span className="discount"><b>${this.props.restaurant.price * this.props.restaurant.restaurant.discount}</b></span>
</div>
</div>
<div className="d-flex col-xs-4">
<img src={this.props.restaurant.images[0]} style={{width: '100%', height: 250, objectFit: 'cover'}} />
</div>
</div>
</div>
</div>
You should only have to adjust the "col" className so that it is always 8 and 4 on any breakpoint.

Related

prevent resizing of parent by child

I allow myself to post my problem because I can't find a solution and I'm starting to pull my hair out.
I would like to make my second column the same height as my first column.
Concern is that since the content is larger than the initial size, it enlarges the parent div and therefore increases the content of the page.
I specify that I use Boostrap 5
My code:
<div className="row g-2">
<div className="col-md-5">
<div className='border border-primary border-4 bg-secondary' style={{ height: 400 + "px" }}></div>
</div>
<div className="col-md-7">
<div className='border border-primary border-4 bg-dark p-2 h-100 overflow-auto'>
<div className="bg-danger" style={{ height: 800 + "px" }}>
<span className="text-white fs-1">Hello World </span>
</div>
</div>
</div>
</div>
The problem in question
Here is what I want
Adding fixed height to parent element can be a solution. Also don't forget overflow class to parent.
<div className="row g-2 overflow-hidden" style={{ height: '400px' }}>
<div className="col-md-5">
<div
className="border border-primary border-4 bg-secondary"
style={{ height: 400 + 'px' }}
></div>
</div>
<div className="col-md-7">
<div className="border border-primary border-4 bg-dark p-2 h-100 overflow-auto">
<div className="bg-danger" style={{ height: 800 + 'px' }}>
<span className="text-white fs-1">Hello World </span>
</div>
</div>
</div>
</div>
Update:
What I'm really looking for is that column two is the same height as column one (its height will be automatic with the content).
You can achieve this by making second column relative and its child absolute. Also add top, bottom, left and right to 0
<div className="row g-2">
<div className="col-md-5">
<div
className="border border-primary border-4 bg-secondary"
style={{ height: 400 + 'px' }}
></div>
</div>
<div className="col-md-7 position-relative">
<div className="border position-absolute top-0 start-0 end-0 bottom-0 border-primary border-4 bg-dark p-2 h-100 overflow-auto">
<div className="bg-danger" style={{ height: 800 + 'px' }}>
<span className="text-white fs-1">Hello World </span>
</div>
</div>
</div>
</div>

media query not working int the below code - Recact js

In the below code the media query not working. Please help if any mistake I did.
I used paragraph media query the below. When I checked in mobile mode t is not working.
/* eslint-disable react/jsx-no-target-blank /
/ eslint-disable react/no-unescaped-entities */
import React from 'react'
import { DropdownButton, Dropdown } from 'react-bootstrap'
const ProfileInfo = () => {
const paragraph = {
position: 'absolute',
top: '66px',
right: '108px',
'#media screen and (min-width: 610px)': {
position: 'static'
}
}
return (
<div className="container-fluid">
<div className="row clearfix">
<div className="col-md-6 col-sm-12"> </div>
<div className="col-md-6 col-sm-12"> </div>
</div>
<div className="row" style={{ margin: 'auto', width: '50%' }}>
<div className="alert alert-success col-md-12 col-sm-12">
<h5 className="alert-heading">Aktive meldinger</h5>
<p>
Hahahahahhhhhfgdfgf gdfgdfgffgdfggfhgh fgdfgdfgfgfg
</p>
</div>
</div>
<div className="row clearfix">
<div className="col-md-6 col-sm-12">
<div className="card mb-3 shadow-sm p-3 bg-white rounded" >
<h5 className="card-title" style={{ color: '#009540' }}><strong>Profile: </strong> </h5>
<p className="card-text"><strong>Navn: </strong> Bengt Nilsfors</p>
<p className="card-text"><strong>Kontaktinformasjon: </strong> 95833897, nilsfors#gmail.com</p>
<DropdownButton id="dropdown-basic-button" variant="outline-primary"
title="Address">
<Dropdown.Item href="#/action-1">Address1 </Dropdown.Item>
<Dropdown.Item href="#/action-2">Address2</Dropdown.Item>
<Dropdown.Item href="#/action-3">Address3</Dropdown.Item>
</DropdownButton>
<p className="card-text"><strong>Adresse: </strong> Nøkken 7 H0101, 9016 Tromsø</p>
<p className="card-text"><strong>Passord: </strong> ***********</p>
<button className="btn btn-success">Rediger</button>
</div>
</div>
<div className="col-md-6 col-sm-12">
<div className="card mb-3 shadow-sm p-3 bg-white rounded" >
<h5 className="card-title" style={{ color: '#009540' }} ><strong>Nettverksanalyse</strong></h5>
<img className="card-img" variant="top" src="../images/testimg.png" style={{ width: '152px' }} />
<div style= { paragraph }>17:58:55: Henter nettverskinfo...<br/>
18:00:31: Nettverkstatus ok. Ingen feil funnet.</div>
<button className="btn btn-warning mt-2 text-center">See details</button>
</div>
</div>
</div>
<div className="row">
<div className="col-md-4 mt-5 text-center">
<div className="card mb-3 shadow-sm p-3 bg-white rounded" >
<div className="card-body">
<h5 className="card-title" style={{ color: '#009540' }}>Abonnement</h5>
<p className="card-text"><strong>Internett</strong></p>
<p className="card-text">Giga (1000/1000) Kr 699,- per mnd.</p>
Oppgrader
</div>
</div>
</div>
<div className="col-md-4 mt-5 text-center">
<div className="card mb-3 shadow-sm p-3 bg-white rounded">
<div className="card-body">
<h5 className="card-title" style={{ color: '#009540' }}>Faktura</h5>
<ul className="list-group" style= {{ float: 'left' }}>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Mars 2021</a></li>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Desember 2020</a></li>
<li><a className="card-link"href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Februar 2021</a></li>
</ul><ul className="list-group" style={{ float: 'right' }}>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Desember 2020</a></li>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}> November 2020</a></li>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Oktober 2020</a></li>
</ul>
<div style={{ marginTop: '76px' }}> Se alle</div>
</div>
</div>
</div>
<div className="col-md-4 mt-5 text-center">
<div className="card mb-3 shadow-sm p-3 bg-white rounded">
<div className="card-body">
<h5 className="card-title" style={{ color: '#009540' }}>Kontakt oss</h5>
<p className="card-text">Kontakt oss via chat eller telefon 38 99 01 00.</p>
Chat
</div>
</div>
</div>
</div>
</div>
)
}
export default ProfileInfo
t's not the problem with react its with the CSS code. If you apply two rules that collide to the same elements, it will choose the last one that was declared. So put the #media queries to the end of the CSS page. i.e
.footer
.column
.social-column-container
.logo {
width: 100px;
height: auto;
display: inline-block;
margin-left: 50px;
}
#media only screen and (min-width: 900px) {
.footer
.column
.social-column-container
.logo {
display: none;
}
}

How to add an svg image so that it highlights on hover

class Menu extends React.Component {
render() {
return(
<div className="collapse navbar-collapse" id="navbarSupportedContent">
<div className="navbar-nav m-auto">
<div className="nav-item" >
<a className="nav-link" href="#">
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 24 24"><path d="M3 4v16h18V4H3zm16 14H5V8h14v10z"/></svg>
LINK
</a>
</div>
</div>
</div>
);
}
}
class Navbar extends React.Component {
render() {
return (
<div className="navbar navbar-expand-lg navbar-light" style={{background: "whitesmoke",height:"90px" }}>
<a className="navbar-brand" href="#" style={{padding: "0"}}>
<div style={{display: "flex", width: "auto", height: "100px"}}>
<div style={{display: "block", height: "100px", width: "80px"}}>
<img src="https://img.icons8.com/dusk/64/000000/cat-profile.png" width="80px" height="80px" alt="" />
</div>
<div style={{display: "block", height: "100px", paddingTop: "20px" }}>
<span style={{display: "flex", fontSize: "24px", marin: "0px", textAlign: "center"}}>BRAND</span>
<span style={{display: "flex", fontSize: "12px", color: "blue", textAlign: "center", padding: "0 2px" }}>Brand Tagline Here</span>
</div>
</div>
</a>
<button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span className="navbar-toggler-icon"></span>
</button>
<Menu />
</div>
);
}
}
ReactDOM.render(
<Navbar />, document.getElementById('content')
);
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<head>
<body>
<div id="content">
Profile icon by Icons8</div>
</body>
<html>
I am using react and bootstrap through CDN and i want to have a navbar that have svg images before navigation links. How to add a fill color on svg when i hover?
I have created navbar as a component, the menu wrapper as a component but i want to fill svg and corresponding navigation menu together
Try adding some CSS or SASS like a:hover, svg:hover { fill: red; color: red !important; }.
class Menu extends React.Component {
render() {
return(
<div className="collapse navbar-collapse" id="navbarSupportedContent">
<div className="navbar-nav m-auto">
<div className="nav-item" >
<a className="nav-link" href="#">
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 24 24"><path d="M3 4v16h18V4H3zm16 14H5V8h14v10z"/></svg>
LINK
</a>
</div>
</div>
</div>
);
}
}
class Navbar extends React.Component {
render() {
return (
<div className="navbar navbar-expand-lg navbar-light" style={{background: "whitesmoke",height:"90px" }}>
<a className="navbar-brand" href="#" style={{padding: "0"}}>
<div style={{display: "flex", width: "auto", height: "100px"}}>
<div style={{display: "block", height: "100px", width: "80px"}}>
<img src="https://img.icons8.com/dusk/64/000000/cat-profile.png" width="80px" height="80px" alt="" />
</div>
<div style={{display: "block", height: "100px", paddingTop: "20px" }}>
<span style={{display: "flex", fontSize: "24px", marin: "0px", textAlign: "center"}}>BRAND</span>
<span style={{display: "flex", fontSize: "12px", color: "blue", textAlign: "center", padding: "0 2px" }}>Brand Tagline Here</span>
</div>
</div>
</a>
<button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span className="navbar-toggler-icon"></span>
</button>
<Menu />
</div>
);
}
}
ReactDOM.render(
<Navbar />, document.getElementById('content')
);
a:hover, svg:hover { fill: red; color: red !important; }
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<head>
<body>
<div id="content">
Profile icon by Icons8</div>
</body>
<html>

Why is this not responsive?

I coded this layout but it's not responsive. The image doesn't seem to respond as it needs to. Can someone help me with this.
I wanted the code to respond to image where it is able to re-size itself as the browser size is adjusted. However i can only see that the images sort of align as I re-size the browser but it fails to change the sizes. I am not sure what is going on in here. Seems like i have all the code placed in but still doesn't work.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
box-sizing: border-box;
}
.row::after {
content: "";
clear: both;
display: block;
}
[class*="col-"] {
float: left;
padding: 15px;
}
html {
font-family: "Lucida Sans", sans-serif;
.responsive {
width: 100%;
height: auto;
}
}
.header {
background-color: #9933cc;
color: #ffffff;
padding: 15px;
}
.menu ul {
list-style-type: none;
margin: 0;
padding: 0;
list-style: none;
}
.menu li {
padding: 2px;
margin-bottom: -0.5px;
color: #ffffff;
.center {
margin: auto;
width: 60%;
border: 3px solid #73AD21;
padding: 10px;
}
/* For desktop: */
.col-1 {width: 8.33%;}
.col-2 {width: 16.66%;}
.col-3 {width: 25%;}
.col-4 {width: 33.33%;}
.col-5 {width: 41.66%;}
.col-6 {width: 50%;}
.col-7 {width: 58.33%;}
.col-8 {width: 66.66%;}
.col-9 {width: 75%;}
.col-10 {width: 83.33%;}
.col-11 {width: 91.66%;}
.col-12 {width: 100%;}
#media only screen and (max-width: 768px) {
/* For mobile phones: */
[class*="col-"] {
width: 100%;
}
}
</style>
</head>
<body>
<div class="row">
<div class="col-4 menu">
<img src="https://via.placeholder.com/300X150" />
</div>
<div class="col-8">
<div class="col-2">
<img src="https://via.placeholder.com/150X50" class="responsive"/>
</div>
<div class="col-2">
<img src="https://via.placeholder.com/150X50" class="responsive"/>
</div>
<div class="col-2">
<img src="https://via.placeholder.com/150X50" class="responsive"/>
</div>
<div class="col-2">
<img src="https://via.placeholder.com/150X50" class="responsive"/>
</div>
<div class="col-2">
<img src="https://via.placeholder.com/150X50" class="responsive"/>
</div>
<div class="col-2">
<img src="https://via.placeholder.com/150X50" class="responsive"/>
</div>
</div>
</div>
<div class="col-3">
<div class="col-3 menu">
<div>
<ul>
<li> <img src="https://via.placeholder.com/300X50" class="responsive"/></li>
<li> <img src="https://via.placeholder.com/300X50" class="responsive"/></li>
<li> <img src="https://via.placeholder.com/300X50" class="responsive"/></li>
<li> <img src="https://via.placeholder.com/300X50" class="responsive"/></li>
<li> <img src="https://via.placeholder.com/300X50" class="responsive"/></li>
<li> <img src="https://via.placeholder.com/300X50" class="responsive"/></li>
</ul>
</div>
</div>
<div class="col-3 menu">
<div>
<ul>
<li> <img src="https://via.placeholder.com/505X250" class="responsive"/></li>
</ul>
</div>
</div>
<div class="col-3 menu">
<div>
<ul>
<li> <img src="https://via.placeholder.com/505X250" class="responsive"/></li>
</ul>
</div>
</div>
<div class="col-3 menu">
<div>
<ul>
<li> <img src="https://via.placeholder.com/505X250" class="responsive"/></li>
</ul>
</div>
</div>
<div class="col-3 menu">
<div>
<ul>
<li> <img src="https://via.placeholder.com/505X250" class="responsive"/></li>
</ul>
</div>
</div>
</div>
<div>
<ul>
<img src="https://via.placeholder.com/305X130" /> <br/>
<img src="https://via.placeholder.com/150X50" />
<img src="https://via.placeholder.com/150X50" /> <br/>
<img src="https://via.placeholder.com/150X50" />
<img src="https://via.placeholder.com/150X50" />
</ul>
</div>
</body>
</html>
Here you go:
https://codepen.io/panchroma/pen/EeaoyP
There were two simple syntax errors in your CSS, I added a closing curly bracket at line 20 and commented out line 28 in your HTML.
What was happening without these corrections is that there was no max-width for your images and they weren't scaling at narrow viewports.
Good luck!
HTML
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
box-sizing: border-box;
}
.row::after {
content: "";
clear: both;
display: block;
}
[class*="col-"] {
float: left;
padding: 15px;
}
html {
font-family: "Lucida Sans", sans-serif;
} /* added closing bracket */
.responsive {
width: 100%;
height: auto;
}
/* } commented out this bracket */
.header {
background-color: #9933cc;
color: #ffffff;
padding: 15px;
}
.menu ul {
list-style-type: none;
margin: 0;
padding: 0;
list-style: none;
}
.menu li {
padding: 2px;
margin-bottom: -0.5px;
color: #ffffff;
.center {
margin: auto;
width: 60%;
border: 3px solid #73AD21;
padding: 10px;
}
/* For desktop: */
.col-1 {width: 8.33%;}
.col-2 {width: 16.66%;}
.col-3 {width: 25%;}
.col-4 {width: 33.33%;}
.col-5 {width: 41.66%;}
.col-6 {width: 50%;}
.col-7 {width: 58.33%;}
.col-8 {width: 66.66%;}
.col-9 {width: 75%;}
.col-10 {width: 83.33%;}
.col-11 {width: 91.66%;}
.col-12 {width: 100%;}
#media only screen and (max-width: 768px) {
/* For mobile phones: */
[class*="col-"] {
width: 100%;
}
}
</style>
</head>
<body>
<div class="row">
<div class="col-4 menu">
<img src="https://via.placeholder.com/300X150" />
</div>
<div class="col-8">
<div class="col-2">
<img src="https://via.placeholder.com/150X50" class="responsive"/>
</div>
<div class="col-2">
<img src="https://via.placeholder.com/150X50" class="responsive"/>
</div>
<div class="col-2">
<img src="https://via.placeholder.com/150X50" class="responsive"/>
</div>
<div class="col-2">
<img src="https://via.placeholder.com/150X50" class="responsive"/>
</div>
<div class="col-2">
<img src="https://via.placeholder.com/150X50" class="responsive"/>
</div>
<div class="col-2">
<img src="https://via.placeholder.com/150X50" class="responsive"/>
</div>
</div>
</div>
<div class="col-3">
<div class="col-3 menu">
<div>
<ul>
<li> <img src="https://via.placeholder.com/300X50" class="responsive"/></li>
<li> <img src="https://via.placeholder.com/300X50" class="responsive"/></li>
<li> <img src="https://via.placeholder.com/300X50" class="responsive"/></li>
<li> <img src="https://via.placeholder.com/300X50" class="responsive"/></li>
<li> <img src="https://via.placeholder.com/300X50" class="responsive"/></li>
<li> <img src="https://via.placeholder.com/300X50" class="responsive"/></li>
</ul>
</div>
</div>
<div class="col-3 menu">
<div>
<ul>
<li> <img src="https://via.placeholder.com/505X250" class="responsive"/></li>
</ul>
</div>
</div>
<div class="col-3 menu">
<div>
<ul>
<li> <img src="https://via.placeholder.com/505X250" class="responsive"/></li>
</ul>
</div>
</div>
<div class="col-3 menu">
<div>
<ul>
<li> <img src="https://via.placeholder.com/505X250" class="responsive"/></li>
</ul>
</div>
</div>
<div class="col-3 menu">
<div>
<ul>
<li> <img src="https://via.placeholder.com/505X250" class="responsive"/></li>
</ul>
</div>
</div>
</div>
<div>
<ul>
<img src="https://via.placeholder.com/305X130" /> <br/>
<img src="https://via.placeholder.com/150X50" />
<img src="https://via.placeholder.com/150X50" /> <br/>
<img src="https://via.placeholder.com/150X50" />
<img src="https://via.placeholder.com/150X50" />
</ul>
</div>
</body>
</html>

Cypress with the ContextMenu not work - React Contextify

i'm using a library called React Contexty, and it has a menu that is inside of the Contextify and is called of ContextMenu, when i do request for it to click in the Item of the ContextMenu, it click but the action not happens.
Cypress:
cy.get("img[data-test=img--menu-candidate]")
.click({
force: true
})
cy.get(".testinhoImg").click({
force: true
})
My MenuContext:
<ContextMenu id={`menu-${this.props.candidate.id}`} animation={animation.fade} theme={theme.light}>
<Item>
<div style={{ width: '50px', marginLeft: '0.5em', marginRight: '0.5em' }}>
<img src={ViewSrc} alt="View" />
</div>
<span className="ibm-plex-sans-serif-regular ibm-textcolor-blue-60"> View </span>
</Item>
Somebody know why? And help-me please?
HTML:
<div class="react-contexify react-contexify__theme--light react-contexify__will-enter--fade" style="left: 447px; top: 308px; opacity: 1;">
<div>
<div class="react-contexify__item" role="presentation">
<div class="react-contexify__item__data">
<div style="width: 50px; margin-left: 0.5em; margin-right: 0.5em;"><img src="/static/media/view.2844f64a.svg" alt="View"></div><span class="ibm-plex-sans-serif-regular ibm-textcolor-blue-60"> View </span></div>
</div>
<div class="react-contexify__separator"></div>
<div class="react-contexify__item" role="presentation">
<div class="react-contexify__item__data">
<div style="width: 65px;"><img src="/static/media/move.f7f8dc44.svg" alt="Move to folder" style="margin-left: 0.5em; margin-right: 0.5em;"></div><span class="ibm-plex-sans-serif-regular ibm-textcolor-blue-60">Move to folder</span></div>
</div>
<div class="react-contexify__item" role="presentation">
<div class="react-contexify__item__data">
<div style="width: 50px; padding-right: 1em;"><img src="/static/media/email.330dcb30.svg" alt="Send Email" style="padding-right: 1em;"></div><span class="ibm-plex-sans-serif-regular ibm-textcolor-blue-60">Send Email</span></div>
</div>
<div class="react-contexify__item react-contexify__item--disabled" role="presentation">
<div class="react-contexify__item__data">
<div style="width: 65px;"><img src="/static/media/remove-folder.d620c9fb.svg" alt="Move to folder" style="margin-left: 0.5em; margin-right: 0.5em;"></div><span class="ibm-plex-sans-serif-regular ibm-textcolor-blue-60">Remove from folder</span></div>
</div>
<div class="react-contexify__item" role="presentation">
<div class="react-contexify__item__data">
<div style="width: 50px; margin-left: 0.5em; margin-right: 0.5em;"><img src="/static/media/delete.e899d653.svg" alt="Delete" style="padding-right: 1.2em;"></div><span class="ibm-plex-sans-serif-regular ibm-textcolor-blue-60">Delete</span></div>
</div>
</div>
</div>

Resources