Wj-popup with scrollable content - hidden div

Posted by: seaninglis on 1 January 2022, 8:48 am EST

    • Post Options:
    • Link

    Posted 1 January 2022, 8:48 am EST

    I’m using the wj-popup element in Angular2 to host a component, and the contents of that component need to scroll if required.

    In my source, the html looks like this:

    <wj-popup #mainImages
    	      class="scrollable-container"
              style="max-height:50%;height:50%;">
    	<app-scrollablegallery></app-scrollablegallery>
    </wj-popup>
    

    but when the code is rendered in the dom, it looks like this:

    <wj-popup #mainImages
    	      class="scrollable-container"
              style="max-height:50%;height:50%;">
                <div>
    	          <app-scrollablegallery></app-scrollablegallery>
                </div>
    </wj-popup>
    

    i.e. an extra

    container is synthesised around my actual content.

    I’ve simplified that a lot, but what it boils down to is that I need to be able to apply “height: 100%” to the mystery div in order for the to be constrained and for the scrolling to kick in as required.

    For some reason, I don’t seem to be able to get this to work.

    If I inspect the DOM, and manually apply “height:100%” to the style attribute of the

    , it works correctly.

    If I attempt to do it via CSS:

    wj-popup.scrollable-container > div {

    background-color: pink;

    height: 100%;

    }

    the class is not applied to the

    element when I inspect the DOM

    But if I attempt to target the parent with:

    wj-popup.scrollable-container {

    background-color: red;

    }

    the class is applied to the parent in the DOM (and I can see it’s red for debugging purposes).

    I can’t for the life of me see what I’m doing wrong?

    Is there any particular trick to hosting scrollable content within a wj-popup I should be aware of?

  • Posted 1 January 2022, 9:00 am EST

    Typically I see the answer just after posting.

    “wj-popup.scrollable-container” is correctly scoped and applied to the host component

    “wj-popup.scrollable-container > div” isn’t correctly scoped and I’m not sure what the syntax is to get that to work.

    Adding “wj-popup.scrollable-container > div {…}” to my styles.css after including wijmo.css works.

    I’d still be interested to know if there’s a more reliable way to achieve scrolling content in this way.

  • Posted 2 January 2022, 6:39 pm EST

    Hello,

    You may either set a CSS class to the “div” element or use the “scrollable-container” class to apply the CSS of its child div element. Please refer to the code snippet and sample link below demonstrating both:

    
    .scrollable-container > div{
        background: pink;
        height: 150px;
        overflow: auto
    }
    
    or
    
    /* directly apply the styling to the div element by assigning a class */
    .scroll{
        height: 150px;
        overflow: auto
    }
    
    

    Sample link: https://jscodemine.grapecity.com/share/munIXulnGUW3cNp66HJPKg/

    Regards

  • Posted 15 January 2022, 12:13 pm EST

    Hi Sonu,

    My question was poorly phrased, but your sample code is great to illustrate my point now I come back to it.

    A simple observation first: I can’t directly style the inner

    div
    as suggested because it’s not inserted as part of my content, it seems to be automatically inserted by the code in the popup control so I have no direct control over it.

    In your sample code, you’re showing

    frmLoginPopup
    . If you inspect the generated code in the dom, you can see

    wj-popup > div > div(class=scroll)

    it’s the extra new div I was trying to style, not the div I that I actually add as part of my own html.

    Second - and more of a problem - these methods don’t seem to work if I want my modal content to occupy a percentage of the screen rather than a fixed pixel value.

    If you alter to a percentage in your sample you’ll see what I mean.

    Ultimately I want the modal to flex to exactly accomodate it’s content, but to expand only to a maximum percentage, and then for the content to scroll. (actually for part of the content, but keeping it simple for now).

    I’m struggling to get this to work.

    Thanks.

  • Posted 17 January 2022, 9:49 pm EST

    Hi,

    1. This is by design. The extra div is added by the control to keep the content within a wrapper div.

      We may style this div using the Parent class and div using the following code:
    
    .scrollable-container > div{
        background: pink;
        height: 300px;
        overflow: auto
    }
    
    
    1. The Popup height cannot be set in the % using the direct CSS. For this, we need to handle the showing event for Popup and set the hostelement height in %.

      Please refer to the following updated demo sample for reference:

      https://jscodemine.grapecity.com/share/ycadtwclOUqQT5d5JSelfQ/

    Regards,

    Manish Gupta

  • Posted 18 January 2022, 5:16 am EST

    Hi Manish,

    Thanks for the link. Applying the style in this way has solved most of my problems.

    The last remaining thing is the behaviour I see here where the width of the popup may vary according to content:

    https://jscodemine.grapecity.com/share/d2xlbi5Ebk_SmVdxVO9msw/

    If you keep clicking the button, the position seems to be reused between calls, leading to the dialog position looking incorrect most of the time.

    Ensuring that removeOnHide - https://www.grapecity.com/wijmo/api/classes/wijmo_input.popup.html#removeonhide - is set didn’t seem to make a difference.

  • Posted 19 January 2022, 2:12 am EST

    Hi,

    The issue is because of the dynamic width and updated content. For this, we need to handle the shown event and calculate the left position and set to the left property for style.

    For this, please refer to the following demo sample for reference:

    https://jscodemine.grapecity.com/share/oU6-LIybGE28tD-5gJRMAQ/

    Regards,

    Manish Gupta

  • Posted 24 January 2022, 7:19 pm EST

    Hi Manish,

    Thanks, but I’m still having issues where anything other than scrolling the entire content of the dialog is required, and they all seem to stem from the after-the-fact styling on the inserted div.

    I can work around this somewhat by expressing the desired height and width of my content in

    vw
    and
    vh
    units as I’m really interested in the popup content occupying a proportion of the viewport and not the parent, and this seems to allow my desired content to have a fixed width and height to work off when arranging itself.

    I’m open to the possibility my CSS has some sort of issue, but manually fixing the height and width of that div in chrome tools always fixes it.

    Using a 100ms timer to reposition is also still very hit-and-miss and I’ve ended up having to queue up a series of timers in rxjs at 0, 100, 250 and 500ms so that the reposition occurs as quickly as possible for aesthetic purposes, but also doesn’t get applied too early.

  • Posted 27 January 2022, 1:22 am EST

    Hello,

    Sorry but we are still unable to replicate the issue at our end, would you please confirm if you are facing the issue in the above-shared sample too? if so then please share some screenshots/gifs of the exact issue. If you are only facing the issue in your application then it might be possible that some other factors could be the reason for the cause. As we are unable to replicate the issue at our end we would request you to please share a minimized version of your application so that we can investigate and find the cause of the issue. We apologize but without a sample to replicate, we cannot comment on the nature of the issue.

    You can also modify the above-shared sample to replicate the issue and send us back for further investigation.

    Regards

  • Posted 31 January 2022, 12:59 am EST

    Hi Sonu,

    Sorry quite difficult to boil it down to a simple example, but I’m satisfied this now lies in my code to fix:

    • "

    • “The actual dialog content contains a flexgrid and the contents of the flexgrid are populated with an asynchronous DB call”

    • “The CSS in the dialog content specifies minimum and maximum values for height and width, ensuring that the flexgrid will scroll if it would otherwise be too large.”

    • “When the wj-popup shows, it correctly centers according to the size of the content it knows about at the time.”

    • “When my async call finishes some time later, the flexgrid is populated, usually resulting in a change of size for the dialog content if there is a lot of data.”

    • “The dialog content does resize according to my CSS, but the top and left position stay the same, resulting in the content occasionally appearing skewed or clipped.”

    "

    As this is the case, I think the wj-popup behaviour is reasonable - and more importantly predictable - and the fix to allow for this belings in my code not yours.

    There are quite a few ways I can approach this now I understand the behaviour, so I’m happy to mark as answered, thanks!.

    Edit to add - reading your original answer back, I can see that you did state this in the first couple of sentences. I just didn’t grasp it at the time.

  • Posted 31 January 2022, 4:44 pm EST

    Hello,

    We are glad that you are able to resolve the issue. Thank you for sharing your thoughts on this.

    Regards

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels