question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with toggling between galleries on same page

See original GitHub issue

If a page has more than one gallery when toggling between them currentIndex still points to the previous one. In example below this causes second gallery to appear without any image. Because it has only one item and index 1 does not exist.

Issue example

Example repo.

I have fixed it in componentDidUpdate adding this:

   if (itemsChanged) {
      this._handleResize();
      this.setState({ currentIndex: this.props.startIndex });
    }

But its not ideal as newly mounted gallery will still inherit currentIndex from previous one when items.length is same.

I assume it’s a flaw or is it expected behaviour and I’m doing something fundamentally wrong here?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
xiaolincommented, Jul 5, 2019

fixed in commit 52c0cc7

0reactions
xiaolincommented, Jun 25, 2019

Thank you, looks to be a bug as new currentIndex prop is not respected.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Toggling Between 2 Images Not Working, Using setInterval
New to JS. I am trying to toggle between showing two images, dragon.svg , and dragon1.svg , every 1 second starting on page...
Read more >
Multiple galleries same page and pagination issues
When 2 galleries appear on the same page, they are always different galleries, never the same one twice.
Read more >
Gallery sections
Add gallery sections to your pages to display sets of images in striking layouts instead of adding multiple image blocks to a block...
Read more >
How to Fix Common Image Issues in WordPress
Beginner's guide to fix common image issues in WordPress such as how to create image gallery, align images, add captions in WordPress, ...
Read more >
Why Are Web Page Images Not Showing?
One way to diagnose this problem is to see if the image is being hosted on an alternate server. If it is, try...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found