Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Merge requests
  • !36648

Add Hash/History helper to handle offcanvas functionality

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open GeoSot requested to merge gs/add-history-helper into main Jun 29, 2022
  • Overview 1
  • Commits 2
  • Pipelines 0
  • Changes 3

This PR is a first approach trying to make some UX improvements on Offcanvas plugin

It has been buzzing to my ears many times (mostly by designers), that Modals & Offcanvases in order to provide a better user experience, should react on browser history changes.

The simple requirement was : "Should close when the user goes back (swipe back / press back btn, etc)"

So as the #36604 was just another one trigger that shouted the same need

Main functionality:

  • offcanvasInstance.show() => adds a hash on our browser address bar (window.location) & adds an entry to the browser's session history stack.
  • offcanvasInstance.hide() => removes the hash from our address bar & replicates a history backward step
  • if User change the hash on his/her address bar, and the hash matches to a component registered pattern, we call a callback where we can decide if we are going to handle. In the specific case, we toggle the offcanvas according to the hash existence. Cases:
    • when user goes back & forward,
    • if user adds/removes a hash
    • if User enters a link on his/her browser address bar and contains a hash

Preview:

https://deploy-preview-36648--twbs-bootstrap.netlify.app/docs/5.2/components/offcanvas/#bs-offcanvas-staticBackdrop

Needs:

  • Feedback (programmatic & functional scope)
  • tests (test new functionality, check existing)

closes #36647

Future applications:

  • Modal can copy the same functionality.
  • ScrollSpy may use it on smoothscroll ref:
    • #36387
    • #36402
  • Tabs could be open (pretty sure we had an issue for this) ref:
    • #25220
  • Collapsibles could be triggered ref:
    • #34299
  • Tabs could be shown
    • #25220
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: gs/add-history-helper