foundation-apps icon indicating copy to clipboard operation
foundation-apps copied to clipboard

Setting overlayClose via modalFactory does not work because of casing

Open PoyangLiu opened this issue 9 years ago • 7 comments

When creating a dialog using modalFactory modalFactory({ overlayClose: "false" })

and the "prop=overlayClose" property is added to the attribute element.attr(prop, config[prop]);

the attribute becomes lowercase "overlayclose" in the attrs object of the modal directive. attrs.overlayclose === "false"

This results in the scope.overlayClose to always be true scope.overlayClose = attrs.overlayClose === 'false' ? false : true;

I resolve this by scope.overlayClose = (attrs.overlayClose || attrs.overlayclose) === 'false' ? false : true;

I assume the same will apply to other capitalized properties such as "animationIn" and "animationOut"

PoyangLiu avatar Jun 16 '15 18:06 PoyangLiu

I should mention that this was discovered in Chrome v43. I did not test it on other browser.

PoyangLiu avatar Jun 17 '15 13:06 PoyangLiu

Facing same issue, with the current code, there is no way to set overlay-close attribute to false.

 if(config[prop]) {
   switch (prop) {
     [...]
     case 'overlayClose':
       element.attr('overlay-close', config[prop] ? 'true' : 'false'); // must be string, see postLink() above

Maybe the line should be simply replaced by element.attr('overlay-close', config[prop]);

https://github.com/zurb/foundation-apps/blob/master/js/angular/components/modal/modal.js#L279

laurent-le-graverend avatar Sep 30 '15 03:09 laurent-le-graverend

This is still an issue. Any timeframe for when this will be fixed?

chr22 avatar Mar 30 '16 08:03 chr22

This was merged and fixed @chr22 Any example of code where it does not work for you?

laurent-le-graverend avatar Mar 30 '16 10:03 laurent-le-graverend

var modal = new this.ModalFactory({
                overlay: true,
                overlayClose: false,
                templateUrl: "Web/Areas/FarmTaskList/FarmTaskAddDialog.html",
                contentScope: {
                    close: () => {
                        modal.destroy();
                    },
                    farmTask: farmTask,
                    farmTasks: this.Tasks
                }
            });

            modal.activate();

The problem is that the the overlayClose attribute won't be added because of the "if" in the picture below when the value is false.

image

And this line only checks if the value is "false", but it will never be false because it will never be added when it is false.

image

chr22 avatar Mar 30 '16 10:03 chr22

Set it as a string 'false'?

laurent-le-graverend avatar Mar 30 '16 10:03 laurent-le-graverend

Thanks it works.

The documentation should be updated to reflect that. The current documentation uses a boolean value.

http://foundation.zurb.com/apps/docs/#!/modal

chr22 avatar Mar 30 '16 10:03 chr22