Skip to Content
author's profile photo Former Member
Former Member

How to avoid auto closing of sap.m.Popover?

Hey,

Is there any (clean) way to avoid the auto closing behaviour of sap.m.Popover or sap.m.ResponsivePopover? I know that there is a property for setting the modality, but that is not what I need because interaction with the background is not possible. In the source code I saw that they make use of sap.ui.core.Popup and that this control supports an auto closing property, which is set to true for the popover classes (except sap.m.MessagePopover).

I am very grateful for any suggestions!

Best regards,

Matthias

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 05, 2016 at 11:50 AM

    In case anyone has a similar problem:

    I managed to solve my issue by creating a custom control that extends from Popover. This way I can also easily use it with an XML fragment. See the code below:

    sap.ui.define([ "sap/m/Popover" ], function(Control) {
        "use strict";
    
        return Control.extend("<namespace>.CustomPopover", {
            init : function() {
                Control.prototype.init.apply(this, arguments);
                this.oPopup.setAutoClose(false);
            },
            renderer : "sap.m.PopoverRenderer"
        });
    });
    

    And the XML fragment:

    <!DOCTYPE xml>
    <core:FragmentDefinition xmlns="sap.m"
        xmlns:core="sap.ui.core" xmlns:util="<namespace>">
        <util:CustomPopover title="{i18n>popoverCustomTitle}"
            afterClose="handlePopoverAfterClose" class="sapUiPopupWithPadding"
            placement="Auto" id="_customPopover">
            <util:content>
                <HBox alignItems="Center">
                    <items>
                        <Input width="100%" id="_customPopoverInput" textAlign="Begin"
                            class="numberInput" type="sap.ui.model.type.Float" editable="true"
                            maxLength="12" />
                        <Label text="{i18n>labelCustomPopover}" width="100%" design="Bold"
                            class="sapUiTinyMarginBegin" />
                    </items>
                </HBox>
            </util:content>
        </util:CustomPopover>
    </core:FragmentDefinition>
    

    Best regards,
    Matthias

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 26, 2016 at 06:29 PM

    the popover doesnt do auto close

    SAPUI5 Explored

    the closing event is because you probably clicked outside of it and it loses focus...

    would a dialog control satisfy your requirement ?

    SAPUI5 Explored

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hello and thanks for the reply,

      I know the dialog, yet my requirements are that I need an open sap.m.Popover and still be able to interact with the background, which is not possible with the Dialog. Currently, the Popover closes when it loses focus.

      Best regards,
      Matthias

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.