In rails 5.2,
Following document order of require statements causing the
Uncaught TypeError: Cannot read property 'hasAttribute' of null
in browser console
Updating the order to
//= require bootstrap
//= require jquery3
//= require popper
fixed the bug