Kendo Popup is not displayed after build and deplyment of React application

2 Answers 582 Views
Popup
Mansi
Top achievements
Rank 1
Iron
Iron
Iron
Mansi asked on 06 Oct 2021, 02:20 PM

Hi,

I have a filter component. I want to show a popup if nothing is selected for "Hobbies" filter.


import React, {useState, useEffect, useCallback} from 'react'
import {DropDownList, MultiSelect} from "@progress/kendo-react-dropdowns"
import {Button} from '@progress/kendo-react-buttons'
import { useHistory, useLocation } from "react-router-dom"
import { Popup } from "@progress/kendo-react-popup"


const Filter = () => {
    
    const history=useHistory()
    const location=useLocation()
    const [Standard,setStandard] = useState("All")
    const [Hobbies,setHobbies] = useState(["Playing"])
    const [Responsibility,setResponsibility] = useState("All")
    const [QueryString,setQueryString] = useState(location.search.substring(1))
    const [Show, setShow] = useState(false)

    const options={
        StandardList:["All","VI","VII","VIII"],
        HobbiesList: ["Playing", "Drawing","Swimming"],
        ResponsibilityList:["All","Monitor","Head","Sports Captain"]
    }

    const handleApply = ()=>{  
        if(!Hobbies.length )
        {
            setShow(true);
        }
        else{
            setQueryString(`Standard=${JSON.stringify(Standard)}&Responsibility=${JSON.stringify(Responsibility)}&IncidentStatus=${JSON.stringify(Hobbies)}`)
        }  
    }

    useEffect(() => {
        var params= new URLSearchParams((QueryString)?(QueryString):`Standard=${JSON.stringify(Standard)}&Responsibility=${JSON.stringify(Responsibility)}&IncidentStatus=${JSON.stringify(Hobbies)}`)
        history.push({search: params.toString()})
    }, [QueryString])

    return (
        <div>
            <label>Standard </label>
            <DropDownList data={options.StandardList} defaultValue={"All"} value={Standard} 
            onChange={(event)=>setStandard(event.target.value)}/> 

            <label > Hobbies </label>
            <MultiSelect data={options.HobbiesList} defaultValue={["Playing"]} value={Hobbies} onChange={(event)=>setHobbies([...event.value])}/>
        
            <label > Responsibility </label>
            <DropDownList data= {options.ResponsibilityList} defaultValue= {"All"} value={Responsibility} onChange={(event)=>setResponsibility(event.target.value)} />

            <Button id="submitFilter" type="button" onClick={handleApply} > Apply </Button>  

            <Popup show={Show} className={'backdrop'} popupClass={'popup-content'}>
                <div id="warning">
                    Please select the Hobbies filter
                </div>
                <div>
                    <Button id="ok" type="button" onClick={()=>setShow(false)}>
                        OK
                    </Button>
                </div>
            </Popup> 
        </div>
    )  
}

export default Filter

This is the styling file that I am using:


.backdrop {
  position: fixed;
  top: 0 !important;
  bottom: 0;
  left: 0 !important;
  right: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.1);
  display: none;
}

.popup-content {
  color: #787878;
  background-color: #f1f1f1 !important;
  border: 1px solid rgba(0,0,0,.05) !important;
  height: 125px;
  width: 425px;
  border-radius: 3px;
  position: fixed;
  left: 530px;
  top: 0px
}

The component works fine with npm start. But when I do npm run build and deploy the application, the kendo popup is not getting displayed, even though there are no build errors. Why am I observing this behaviour?

2 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 07 Oct 2021, 11:49 AM

Hello, Mansi,

This could be connected with styles that are interfering with the component visibility after the build process. I can suggest inspecting the DOM to see if the element is rendered in the DOM after show is set to true.

Also, please check if changing the `Show` variable to `show` will make a difference as in general, the state names should start with lower case, and maybe this is causing issues after the build process.

If the issue still occurs, please share how the application is build and deployed.

Regards,
Stefan
Progress Telerik

Remote troubleshooting is now easier with Telerik Fiddler Jam. Get the full context to end-users' issues in just three steps! Start your trial here - https://www.telerik.com/fiddler-jam.
Mansi
Top achievements
Rank 1
Iron
Iron
Iron
commented on 07 Oct 2021, 12:36 PM

Hi,

I tried changing Show to show, doesn't make any difference.

When I inspect the DOM I don't see popup component getting rendered, and can't understand the reason behind it. Could you help me with it or suggest what can I change to render the popup component successfully?

Thanks,

Mansi

Stefan
Telerik team
commented on 08 Oct 2021, 08:03 AM

Hello, Mansi,

I can suggest a couple of tests:

1) console.log the value of show before render to ensure that it is updated when deployed:

console.log(show)

    return (
        <div>
            <label>Standard </label>
2) When the button is clicked, open the browser console and type this:

document.querySelector('.backdrop')
Also, this seems like a very specific issue that is connected with the built and deploy process. This is why it will be very helpful to share then as the code seems good and we can only guess what could be causing this only based on the code.

Mansi
Top achievements
Rank 1
Iron
Iron
Iron
commented on 11 Nov 2021, 12:28 PM

Hey, I figured it out, the popUp is not getting displayed because of the .backdrop class that I am using. Once I remove this .backdrop class, the popUp is being displayed after build and deployment.

Could you suggest me some other way instead of using backdrop class, to disable all the other functions of a page when a popUp is displayed?

Stefan
Telerik team
commented on 11 Nov 2021, 02:31 PM

Hello, Mansi,

Thank you for the clarification.

This occurs as the backdrop element has a z-index of 999, and the Popup z-index is set to 100 by default. You can leave the backdrop class and set a larger z-index to the Popup in order to show it on top of it:

https://www.telerik.com/kendo-react-ui/components/popup/stack-order/

Mansi
Top achievements
Rank 1
Iron
Iron
Iron
commented on 11 Nov 2021, 08:07 PM | edited

Hello Stefan,

I kept z-index of backdrop 999 and z-index of popup-content 1005. Still it's not appearing. Could you suggest what is going wrong?

 

Mansi
Top achievements
Rank 1
Iron
Iron
Iron
commented on 12 Nov 2021, 06:34 PM | edited


Hi, could you please suggest what's going wrong or a better way to do it?

Regards,

Mansi

Stefan
Telerik team
commented on 15 Nov 2021, 06:21 AM

Hello, Mansi,

Setting the z-index to a larger value should resolve this. I assume there is a small detail we are missing that is causing this. 

I will be happy to help and suggest a solution, but I will need a runnable example reproducing this in order to inspect it locally.

Mansi
Top achievements
Rank 1
Iron
Iron
Iron
commented on 15 Nov 2021, 06:23 AM

Hi Stefan,

Is there an on call support procedure from the kendo team? It would be helpful and easier to resolve this issue on call.

0
Mansi
Top achievements
Rank 1
Iron
Iron
Iron
answered on 15 Nov 2021, 10:45 AM

Hi Stefan,

The issue is resolved.

The following property in the backdrop class was causing this error:

display: none;

Once I removed it, the popup started working fine

Thanks,

Mansi

Tags
Popup
Asked by
Mansi
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Stefan
Telerik team
Mansi
Top achievements
Rank 1
Iron
Iron
Iron
Share this question
or