[v2, hash] navigate to different slides via browser back/forward buttons not working

Author: miedzikdCreated May 21, 2021Updated Oct 12, 2025
LabelsFeature Request

Description

Navigate to different slides via browser back/forward buttons not working When the lgHash plugin is enabled, changing slides creates new hashes, but pressing the back/forward buttons does not change the slides or closes the gallery, but completely reloads the page

Steps to reproduce

  1. Enable hash plugin
  2. Open gallery
  3. Click forward 3 times
  4. Click browser back button

Demo: https://www.lightgalleryjs.com/demos/hash/

Expected result

You should see the previous slide, not close the gallery. On the other hand, when you pressed back on the first slide, the gallery should close but the page should not reload

Actual result

Page is reload

Additional context

Love your work and version 2 ;)

Source: sachinchoolur/lightGallery