support icon indicating copy to clipboard operation
support copied to clipboard

`beforeClose` event should handle asynchronous listeners.

Open ExtAnimal opened this issue 1 year ago • 0 comments

Forum post

Popup.js needs:

    async close() {
        const
            me              = this,
            { closeAction } = me;

        /**
         * Fired when the {@link #function-close} method is called and the popup is not hidden.
         * May be vetoed by returning `false` from a handler.
         * @event beforeClose
         * @preventable
         * @param {Core.widget.Popup} source - This Popup
         */
        if (!me._hidden && (await me.trigger('beforeClose')) === false) {
            // Allow beforeClose to veto if called when we are visible.
            // we should destroy it even if it's hidden just omit beforeclose event
            return;
        }
        if (!me._hidden || closeAction === 'destroy'){
            // Focus moves unrelated to where the user's attention is upon this gesture.
            // Go into the keyboard mode where the focused widget gets a rendition so that
            // it is obvious where focus now is.
            // Must jump over EventHelper's global mousedown listener which will remove this class.
            if (me.containsFocus && me.highlightReturnedFocus) {
                me.setTimeout(() => DomHelper.setFocusRendition(me.rootElement, true), 0);
            }

            // Revert focus early when closing a modal popup will lead to destruction, to give listeners a shot at doing
            // their thing. Without this, focus will be reverted as part of the destruction process, and listeners won't
            // be called.
            me.modal && closeAction === 'destroy' && me.revertFocus();

            me.unmask();

            // Get any errorTip associated with any item in the popup and hide them
            const errorTip = me.items.length && me.items.find(item => item.errorTip)?.errorTip;

            if (errorTip) {
                errorTip.pointerOverOutDetacher?.();
                errorTip.hide();
            }

            return me[closeAction]();
        }
    }

ExtAnimal avatar Aug 08 '24 06:08 ExtAnimal