Smooch chat has elements on top of it, how can I fix this?

165 views Asked by At

I am using this library:

 !function(e,n,t,r){
        function o(){try{var e;if((e="string"==typeof this.response?JSON.parse(this.response):this.response).url){var t=n.getElementsByTagName("script")[0],r=n.createElement("script");r.async=!0,r.src=e.url,t.parentNode.insertBefore(r,t)}}catch(e){}}var s,p,a,i=[],c=[];e[t]={init:function(){s=arguments;var e={then:function(n){return c.push({type:"t",next:n}),e},catch:function(n){return c.push({type:"c",next:n}),e}};return e},on:function(){i.push(arguments)},render:function(){p=arguments},destroy:function(){a=arguments}},e.__onWebMessengerHostReady__=function(n){if(delete e.__onWebMessengerHostReady__,e[t]=n,s)for(var r=n.init.apply(n,s),o=0;o<c.length;o++){var u=c[o];r="t"===u.type?r.then(u.next):r.catch(u.next)}p&&n.render.apply(n,p),a&&n.destroy.apply(n,a);for(o=0;o<i.length;o++)n.on.apply(n,i[o])};var u=new XMLHttpRequest;u.addEventListener("load",o),u.open("GET","https://"+r+".webloader.smooch.io/",!0),u.responseType="json",u.send()
    }(window,document,"Smooch",smooch_key);

And this is how I init:

    function initSmooch() {
    if (!$rootScope.smooch_inited) {
        try {
            var window_focus = true;
            $(window).focus(function() {
                window_focus = true;
            }).blur(function() {
                window_focus = false;
            });

            Smooch.on('message:received', function() {
                if (!window_focus || !Smooch.isOpened()) {
                    //Play sound
                    var audio = new Audio('assets/audio/ding.wav');
                    audio.play();
                }
                Smooch.open();
            });
            var promise = Smooch.init({
                appId: smooch_key,
            });
            promise.then(function() {
                $('#sk-holder').addClass('no-print');
                $rootScope.smooch_inited = true;
                Smooch.updateUser({
                    givenName: $rootScope.data.user.first_name,
                    surname: $rootScope.data.user.last_name,
                    properties: {
                        email: $rootScope.data.user.email,
                        uid: $rootScope.data.user.id,
                        language: $rootScope.data.user.language,
                        country: $rootScope.data.user.country
                    }
                });
            });
        } catch(e) {
            console.log("error trying to init smooch: " + e);
            $timeout(function() {
                initSmooch();
            }, 1000);
        }
    }
}

Looked but I have nothing where I add the view, so I don't know how to modify, force it to be on top. Any ideeas?

Example Picture

1

There are 1 answers

0
mspensieri On BEST ANSWER

This looks like there is a conflict between the Z index of the Web Messenger and the elements beneath it. The Web Messenger already has a very high z-index of 9998, but to fix this issue you'll either need to increase that value more, or decrease the z-index of the elements that appear on top.

For the former, you can insert this CSS rule on your page and tweak the value to something suitable:

#web-messenger-container {
    z-index: 9998;
}

Or write a similar rule targeting the problematic elements and giving them a lower number