Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arctic admin causes JS errors in browser logs #66

Closed
michalzynek opened this issue Nov 23, 2019 · 5 comments · Fixed by #109
Closed

Arctic admin causes JS errors in browser logs #66

michalzynek opened this issue Nov 23, 2019 · 5 comments · Fixed by #109
Labels

Comments

@michalzynek
Copy link

I have error in browser console since I installed arctic admin:

Uncaught TypeError: Cannot read property 'getBoundingClientRect' of undefined

And not only me I guess:
https://stackoverflow.com/questions/52857201/uncaught-typeerror-cannot-read-property-getboundingclientrect-of-undefined-on

@cprodhomme cprodhomme added the bug label Mar 30, 2020
@wachub
Copy link
Contributor

wachub commented May 20, 2020

  • Hi, it seems to occur in this js file at two points here and here.

  • In both those cases, the issue seems to be that when the tabs array is empty, there is a null value related exception when the first element of the empty array is referenced as a DOM object and the getBoundingClientRect() function is called on that.

  • From what I understand, it shouldn't break compatibility with the existing code for the width to be initially set to zero and for the getBoundingClientRect().width function to be called only when the tabs array is not empty.

@michalzynek
Copy link
Author

michalzynek commented May 20, 2020

hello @wachub , thank you for your response

My dirty workaround, for then, was (in application.html.haml - head section):

- if request.url.include? '/admin'
      = javascript_include_tag 'active_admin', 'data-turbolinks-track': 'reload'

As indeed, it broke some of my JS files, I do not remember what it was exactly (old times) but I think related to owl-carousel plugin or iziModal.

@wachub
Copy link
Contributor

wachub commented May 20, 2020

Hi @michalzynek. Could you check out this pull request #75 . Unfortunately I understand very little of rails and I haven't heard of .haml files at all till now. So I am in no position to verify your solution.

Anyway from the little that I do understand, i think your code simply says that the javascript tag should be included when the http request goes to admin. However I think all the activeAdmin js files are included for all http requests by default.

@michalzynek
Copy link
Author

michalzynek commented May 25, 2020

@wachub in my example, the files were not only included on ActiveAdmin module - maybe that was a mistake of my configurations somewhere, but above Haml is simple HTML that says the JS files from ActiveAdmin should only be included under /admin path.

UPDATE: I saw your PR, it may have fixed the error as I see you are checking the tabs existence. However, I am concerned about loading those files in locations different than ActiveAdmin engine

@wachub
Copy link
Contributor

wachub commented Jun 4, 2020

Hi @michalzynek . AFAIK, this bug is a fairly low level one (syntax level), which is independent of the logic/algorithm on top. The only assumption made is that the width can be taken to be zero when the array is empty, which seems consistent for whatever is written on top. I don't think it is likely to blow up anywhere else.

cprodhomme added a commit that referenced this issue Apr 8, 2023
Pull-request : #84
Issue : Closes #66

Adaptation of the code of @vieditcom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants