diff --git a/app/assets/javascripts/application.js.erb b/app/assets/javascripts/application.js.erb index 382e37826..000b7b1de 100644 --- a/app/assets/javascripts/application.js.erb +++ b/app/assets/javascripts/application.js.erb @@ -249,9 +249,12 @@ var HelperModule = (function(){ return exit; }); - const RESIZE_OBSERVER = new ResizeObserver(function(entries) { - entries.forEach((entry) => { - if (entry.target.offsetWidth <= parseInt(entry.target.getAttribute('data-width-breakpoint'))) { + const RESIZE_OBSERVER = new ResizeObserver(entries => { + entries.forEach(entry => { + const { offsetWidth } = entry.target; + const breakpoint = parseInt(entry.target.getAttribute('data-width-breakpoint')); + + if (offsetWidth <= breakpoint && offsetWidth !== 0) { entry.target.classList.add('narrow'); } else { entry.target.classList.remove('narrow');