Nav-Block open modal not working when width exactly at breakpoint

Description:

I added a Nav-Block which switches to mobile or modal view at 992px , the tablet or md breakpoint.
When I set the the inner window width exactly to 992px like the md breakpoint is defined, the modal is not working. At 991px and lower it works. At 993px and higher the desktop view shows up again.

The problem seems to be that the “is-modal” attribute in the element gets removed at 992px. Even though the media queries are still active at 992px.
I tracked it down to the “isModal()” Javascript function. In there it does a lower than (window.innerWidth < CCers.breakpoints.md) rather than lower equal than like the media queries do it with “max-width: 992px”.

Screenshots, screen recording, code snippet
Image of the state when the width is exactly 992px. Clicking the burger menu to open the modal does not work. You can see the invisible modal position by the light blue block in the image that shows up by selecting the element in the browser inspector:

Image of the breakpoints like they are defined in CCers and the Problem in the “isModal()” function:
…okay I can only make one media item in a post. Great!
Here are the code snippets:

var CCers = {
“ajaxurl”: “http://xyz.com/wp-admin/admin-ajax.php”,
“restBase”: “http://xyz.com/wp-json”,
“nonce”: “11c479b617”,
“logoutNonce”: “c907a1a10c”,
“loggedIn”: “”,
“cwiclyDefaults”: “false”,
“postID”: “281”,
“removeIDsClasses”: “true”,
“breakpoints”: {
“md”: 992,
“sm”: 576
}
};

e.prototype.isModal = function() {
if (“lg” === this.breakpoint)
return !0;
if (“md” === this.breakpoint) {
if (window.innerWidth < CCers.breakpoints.md)
return !0
} else if (“sm” === this.breakpoint && window.innerWidth < CCers.breakpoints.sm)
return !0
}

Environment info

  • WordPress version: 6.3
  • Cwicly Plugin version: 1.2.9.9.3

Hi @jan,

Welcome to the community :slight_smile:

Thank you for bringing this to our attention!

I have been able to reproduce the issue with the modal menu not opening at exactly 992px on my end, and can confirm it is a bug.
We’ll be sure to address this as soon as possible.

Apologies for the inconvenience.

1 Like

Hello @jan,

Nice catch and detailed steps + code, really appreciated.
This should be fixed in 1.2.9.9.4.

If you still run into any issues, I’d be grateful if you could let me know by replying to this thread.

Cheers,

Great fix! Sometimes it is the little things that make a big difference - only one pixel but a large improvement :grin: