otto-torino / django-baton

A cool, modern and responsive django admin application based on bootstrap 5 that brings AI to the Django admin - https://baton.sqrt64.it/
MIT License
859 stars 92 forks source link

deactivate auto-scrolldown on tab change #264

Closed etanter closed 10 months ago

etanter commented 10 months ago

Hi,

I noticed that when in a change form, when switching tabs, the page automatically scrolls down a little (how much seems to depend on the content of the page, going from no scroll at all to a few lines). Is there a way to deactivate this and ensure that switching tabs never affects the scroll?

Thanks!

abidibo commented 10 months ago

Hi @etanter, this is due to the usage of the tab identifier as hash in the url. The benefit though, is we're able to share/use an url which opens automatically the desired tab.

etanter commented 10 months ago

Indeed, having hashes in the url is very useful to go to a specific tab, so that must be preserved. I was hoping there's a way to not have it scroll down, maybe with this scroll restoration stuff, but I couldn't make it work.

abidibo commented 10 months ago

@etanter should be addressed in dev branch

etanter commented 10 months ago

Thanks @abidibo! I tried but I still see the scrolling adjustment happening. Maybe I didn't proceed correctly: I modified requirements.txt to include django-baton @ git+https://github.com/otto-torino/django-baton@develop then ran pip install -r requirements.txt. The log seems ok to me, though:

Collecting django-baton@ git+https://github.com/otto-torino/django-baton@develop (from -r requirements.txt (line 8))
  Cloning https://github.com/otto-torino/django-baton (to revision develop) to /private/var/folders/8h/0y4vjvbx123515rv2l67sytw0000gn/T/pip-install-nazo04on/django-baton_d992cc6f0a3c43d18f4fa71de499ce1e
  Running command git clone --filter=blob:none --quiet https://github.com/otto-torino/django-baton /private/var/folders/8h/0y4vjvbx123515rv2l67sytw0000gn/T/pip-install-nazo04on/django-baton_d992cc6f0a3c43d18f4fa71de499ce1e
  Running command git checkout -b develop --track origin/develop
  Switched to a new branch 'develop'
  branch 'develop' set up to track 'origin/develop'.
  Resolved https://github.com/otto-torino/django-baton to commit 74063348e1a008ebf5868958d6662c8bf012a43e
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done

any idea?

abidibo commented 10 months ago

@etanter could it be a cache issue? I checked again and works as expected in my test app

etanter commented 10 months ago

I've restarted the server, Chrome, and used incognito mode + hard refresh. I don't know how to avoid cache issues beyond that. I still experience the scrolling.

etanter commented 10 months ago

just in case: note that for scrolling to happen, the content of the tab needs to be longer than the space of the window.

abidibo commented 10 months ago

just in case: note that for scrolling to happen, the content of the tab needs to be longer than the space of the window.

yeah I know that

abidibo commented 10 months ago

I've restarted the server, Chrome, and used incognito mode + hard refresh. I don't know how to avoid cache issues beyond that. I still experience the scrolling.

Generally a shift+f5 should do the job

abidibo commented 10 months ago

@etanter I've just tried in an existing project:

$ pip uninstall django-baton
$ pip install django-baton@git+https://github.com/otto-torino/django-baton@develop

shift+f5 and it works

etanter commented 10 months ago
> $ pip uninstall django-baton
> $ pip install django-baton@git+https://github.com/otto-torino/django-baton@develop

I tried that and indeed, it works! Excellent :) (not sure why the route via requirements.txt didn't work though, but that doesn't really matter)

abidibo commented 10 months ago

Maybe because the version doesn't change, so uninstalling it first does the job.