medialize / ally.js

JavaScript library to help modern web applications with accessibility concerns
http://allyjs.io/
MIT License
1.53k stars 83 forks source link

Error setting up focusWithin #157

Closed cycomachead closed 7 years ago

cycomachead commented 7 years ago

I'm trying to setup the focusWithin polyfill and I'm setting the following error:

detect-focus.js:11 Uncaught TypeError: Cannot read property 'scrollTop' of null
    at before (detect-focus.js:11)
    at _default (detect-focus.js:93)
    at executeTests (supports.js:87)
    at _default (supports.js:104)
    at Object.engage (focus-within.js:102)
    at Object.initialize (decorate-service.js:33)
    at Object.<anonymous> (ally.js:8)
    at __webpack_require__ (bootstrap c954903…?2dc8:555)
    at fn (bootstrap c954903…?2dc8:86)
    at Object.<anonymous> (application.js:27)

I'm building the app using Webpack and my ally.js file is pretty bare:

import ally from 'ally.js/src/ally.js';

var handle = ally.style.focusWithin();

Any help would be greatly appreciated. :)

cycomachead commented 7 years ago

Ah, I've discovered the error! You can't call focusWithin() before an window.onloador $(document).ready function has fired. If I missed this in docs, whoops. If not, it might be a helpful caveat to add.

Thanks for the awesome library, by the way!