glide icon indicating copy to clipboard operation
glide copied to clipboard

Undefined method slice when clicking on a specific slider bullet.

Open tylercrocker opened this issue 5 years ago • 5 comments

I'm seeing the following error when clicking on individual slider bullet:

glide.esm.js:2046 Uncaught TypeError: Cannot read property 'slice' of null

This is because the event bubbles up to the slider parent during the following event handler (glide.esm.js:3242):

click: function click(event) {
  event.preventDefault();

  Components.Run.make(Components.Direction.resolve(event.currentTarget.getAttribute('data-glide-dir')));
}

event.currentTarget.getAttribute('data-glide-dir') returns nothing, since event.currentTarget doesn't have that attribute, and then the resolve method at glide.esm.js:2045 immediately attempts to call slice(0, 1) on the null object it was passed, and therefore breaks.

While the overarching click event DOES WORK, having this JS error happen is rather silly. Could we have the resolve function verify that it does indeed have something before trying to call slice, the initial offending click event not call resolve if it would pass it nothing, or have the click event not bubble?

Thanks!

(P.S. - I'm more than happy to open a PR for this, I just am not super familiar with the codebase and don't want to make any assumptions about your best practices!)

tylercrocker avatar Jun 13 '19 18:06 tylercrocker

Getting this error too, when trying to call disabled().

atmonello avatar Dec 11 '19 13:12 atmonello

Getting this error too, when trying to call disabled().

Nevermind, it was because I was clicking a button I have included inside the .glide__arrows container, so it was trying to find the same data-glide-dir on my custom button (which didn't have that attribute).

Maybe it can give you any tips, @tylercrocker

atmonello avatar Dec 11 '19 13:12 atmonello

@tylercrocker I am facing the same issue. Can you please share your solution?

Heet1996 avatar Dec 15 '20 10:12 Heet1996

I'm getting this error too :/

juanpablob avatar May 12 '21 15:05 juanpablob

I figured out the reason for my case: it was because I inserted bullets data-glide-el="controls[nav]" into data-glide-el="controls"

Shaidulint avatar Aug 04 '22 14:08 Shaidulint