samvera / hyrax

Hyrax is a Ruby on Rails Engine built by the Samvera community. Hyrax provides a foundation for creating many different digital repository applications.
http://hyrax.samvera.org/
Apache License 2.0
184 stars 124 forks source link

Tab selection lost when changing locale #3766

Open jmfrenzel opened 5 years ago

jmfrenzel commented 5 years ago

Descriptive summary

QA Testing for Hyrax
Hyrax Version: 3.0.0.pre.beta2
Hyrax Branch: master
Hyrax Revision: 05875cb8f40f4d0474f28562e117c009ca979645

Rationale

Changing the locale should keep the page/view content.

Expected behavior

Changing locale keeps the pages/views content.

Actual behavior

Changing locale resets the page/view to the first (default tab).

Steps to reproduce the behavior

  1. go tohttps://nurax-dev.curationexperts.com/concern/file_sets/0z708w57j/edit?locale=en#permissions_display
  2. change the language, e.g. "Deutsch"

Related work

https://github.com/samvera/hyrax/pull/2864

no-reply commented 3 years ago

this is still an issue, and i regret having filed it into the backlog in the past.

i18n locale users shouldn't have to put up with confusing UI behavior.

rjkati commented 3 years ago

This issue is still present in Hyrax 3.0.1

rjkati commented 2 years ago

Tested on nurax-dev running Hyrax 4.0.0.beta1. This is still an issue.

conorom commented 2 years ago

Yup, it sure is. I was looking at this as one of my final tickets as the first Maintenance WG of this year was coming to a close.

As I was mulling over how exactly I would store active tabs so that they would survive a page reload I noticed that the Hyrax home page itself has two sets of Bootstrap tabs on it, such that the URL fragment does not store the current state of active/visible tabs. This makes any solution much more awkward, and in fact sort of breaks good web design practice, I think (I'm no expert but it's nice if the URL indicates the state of the page).

Screen Shot 2022-10-04 at 2 46 09 PM

It's up for debate as to whether that should be addressed before this ticket. It certainly gave me pause for thought on continuing with it as the sprint ended!

But if it's left as-is then I guess multiple active tabs need to be gathered/stored when the new locale link is being clicked (before the page load happens). Working in the console from the screen above:

active_bootstrap_tabs = []
[]

$('li.nav-item > a.nav-link.active').each(function() { active_bootstrap_tabs.push($(this).attr('href')); });

active_bootstrap_tabs
(2) ['#recently_uploaded', '#tab-col2-second']

And then JS will force any tabs in this stored array of tabs to the active state on page loads, while keeping the URL fragment displayed as it was before, ideally.

I won't be working on this anytime soon (I'll take my name off) so I leave it up to someone else to weigh in on whether the multi-tab/URL problem should block this (i.e. a home page redesign, I guess?) or if it should proceed with a this issue as-is, using (perhaps) a solution as described here.