Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[60638] Opening a work package (full view) on mobile auto-scrolls to the tab row when not desired #17939

Conversation

bsatarnejad
Copy link
Contributor

@bsatarnejad bsatarnejad commented Feb 13, 2025

Ticket

https://community.openproject.org/wp/60638

What are you trying to accomplish?

Avoid scrolling to the tabs in small screen devices.

Screenshots

Before:

Screen.Recording.2025-02-13.at.16.54.53.mov

After:

Screen.Recording.2025-02-13.at.16.53.30.mov

What approach did you choose and why?

If there is a fragment identifier in the url(id for comment or an activity for example), page will scroll to the identifier, otherwise there won't be a scroll.

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

Copy link
Contributor

@HDinger HDinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know whether the assumption that we only want to scroll when there is a hash in the URL is really true. It feels dangerous to me.. Why didn't you simply remove the autofocus from the label?

Comment on lines 37 to 42
if (window.location.hash) {
focusable?.focus();
} else {
// Prevent scroll if there's no hash in the URL
focusable?.focus({ preventScroll: true });
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not test this, but this whole block could probably be changed to focusable?.focus({ preventScroll: !!window.location.hash });

if (window.location.hash) {
focusable?.focus();
} else {
// Prevent scroll if there's no hash in the URL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That comment is really not helpful. It is pretty self-explaining, that it should prevent scrolling when there is no hash in the URL, the actual question is why?

@bsatarnejad
Copy link
Contributor Author

I don't know whether the assumption that we only want to scroll when there is a hash in the URL is really true. It feels dangerous to me.. Why didn't you simply remove the autofocus from the label?

I don't know whether the assumption that we only want to scroll when there is a hash in the URL is really true. It feels dangerous to me.. Why didn't you simply remove the autofocus from the label?

If we remove autofocus, there will be some issues for a comment, it won't scroll to the comment set in the URL, for example this test will fail:
./spec/features/activities/work_package/activities_spec.rb:951 # Work package activity auto scrolling scrolls to comment specified in the URL when sorting set to asc when on mobile screen size scrolls to the comment specified in the URL

@HDinger
Copy link
Contributor

HDinger commented Feb 14, 2025

I don't know whether the assumption that we only want to scroll when there is a hash in the URL is really true. It feels dangerous to me.. Why didn't you simply remove the autofocus from the label?

I don't know whether the assumption that we only want to scroll when there is a hash in the URL is really true. It feels dangerous to me.. Why didn't you simply remove the autofocus from the label?

If we remove autofocus, there will be some issues for a comment, it won't scroll to the comment set in the URL, for example this test will fail: ./spec/features/activities/work_package/activities_spec.rb:951 # Work package activity auto scrolling scrolls to comment specified in the URL when sorting set to asc when on mobile screen size scrolls to the comment specified in the URL

Well, this is coincidence.. The fact, that the users is scrolled to the tabs, triggers the turbo frame of the activity panel to be loaded, and thus the page can be scrolled (a second time) to the actual comment. If we move the hidden label to the top of the page, this will also break. So basically, there is an inderdependency between things that are totally unrelated.
That is why, I still think that we should not change the default focus behavior without double checking that this is really what we want. In my opinion, the activity panel should be responsible for scrolling itslef into view if there is a hash on the URL.

@bsatarnejad bsatarnejad requested a review from HDinger February 17, 2025 08:34
@HDinger HDinger merged commit 6af552e into release/15.3 Feb 17, 2025
12 checks passed
@HDinger HDinger deleted the 60638-opening-a-work-package-full-view-on-mobile-auto-scrolls-to-the-tab-row-when-not-desired branch February 17, 2025 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants