openscopeproject / TrguiNG

Remote GUI for Transmission torrent daemon
GNU Affero General Public License v3.0
331 stars 39 forks source link

Focusing a row scrolls the name cell into view #179

Closed jpovixwm closed 6 months ago

jpovixwm commented 6 months ago

Steps to reproduce

  1. Horizontally scroll the torrents table to a point where the Name column is no longer visible.
  2. Click on any row (actually, it happens on mouse down, before the button is released)
  3. The Name column is scrolled into view.

I believe this behavior is unintentional. If it's intentional, I personally find it confusing and unexpected.

It is caused by this code: https://github.com/openscopeproject/TrguiNG/blob/b09f6e9f2207da05632af07347376fca478b6310/src/components/tables/common.tsx#L661-L663

And can potentially be fixed by calling HTMLElement.focus() like this:

ref.current?.focus({ preventScroll: true });

Though I'm not sure if this change won't negatively influence some other scenario, maybe there are cases where the name column/cell should indeed be scrolled into view.

Also reproducible in the Files tab.

qu1ck commented 6 months ago

Not intentional. I didn't do it because I evidently misread the browser compatibility chart and thought it's not supported on most browsers.

Do you wanna send a PR? I can do it too but don't want to steal the credit for the fix :)