cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Answers (2)

Answers (2)

0 Kudos

Please explain more on this correct answer.

SergioG_TX
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Thanks for the reply.

Sorry, I should have been more specific. What I meant is the closing behaviour when I click outside. I need the Popover to stay open when doing so. The sap.m.MessagePopover does that. Is there any way to realize that?

Best regards,

Matthias

Former Member
0 Kudos

Hi,

you can use Dialog instead of popover ...

thanks

Viplove

Former Member
0 Kudos

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