Skip to content
This repository was archived by the owner on Nov 23, 2026. It is now read-only.

Feature/7600 - Scroll to newly created folder - #9145

Merged
JammingBen merged 3 commits into
owncloud:masterfrom
pascalwengerter:feature/7600
Jul 25, 2023
Merged

JammingBen merged 3 commits into
owncloud:masterfrom
pascalwengerter:feature/7600

Conversation

@pascalwengerter

@pascalwengerter pascalwengerter commented Jun 1, 2023 •

Copy link
Copy Markdown
Contributor

Description

Upstreams a CERN commit by @elizavetaRa which originates from before some major refactorings. It also reduces the scrollToResource arguments from a full resource where only the id would be used to a string/number.

Related Issue

}

store.commit('Files/UPSERT_RESOURCE', resource)
await store.commit('Files/UPSERT_RESOURCE', resource)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My IDE suggests there's no difference when using await here, however the scrolling only happens if you put it there 🤷🏽

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't get that either... commit is a synchronous call / doesn't return a promise, so await makes no sense at all...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, thx for the hint!

const fileListWrapperElement = document.getElementsByClassName('files-view-wrapper')[0]
fileListWrapperElement.scrollBy(0, -resourceElement.offsetHeight)
}
resourceElement.scrollIntoView({ behavior: 'smooth', block: 'center' })

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure why all the other code was necessary tbh - scrolling to a resource and centering it on screen seems pretty straightforward, and if we need a "scroll to top" we should implement it explicitly?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

doesn't work with active pagination though. if you're on page 3 and a just created folder is sorted into page 17 you would need to navigate to that page before trying to scroll...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah damn, I knew there was something I was missing (because otherwise that issue would've been resolved long ago already I suppose)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

fine to split it into two issues btw. for this PR: assume that using scrollToResource is sufficient and declare it not checking pagination as bug. Then solve using pagination in scrollToResource as a separate PR.

@JammingBen JammingBen Jun 2, 2023 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure why all the other code was necessary tbh - scrolling to a resource and centering it on screen seems pretty straightforward, and if we need a "scroll to top" we should implement it explicitly?

It was there for the keyboard navigation. Now when navigating via keyboard, it always immediately scrolls to the next resource. Before, it only scrolled when the resource was outside of the viewport. Both works, but I actually like the latter because it does not feel so "floaty". Maybe we can handling things a bit differently when working with keyboard navigation? Pass a param like forceScroll to the method which is false in case of keyboard navigation?

@elizavetaRa

Copy link
Copy Markdown
Contributor

Adding some opinion: scrolling to resource would also make sense when uploading a resource and even when creating new file that opens in new tab

@dschmidt dschmidt mentioned this pull request Jul 10, 2023
37 tasks done
@tbsbdr tbsbdr added this to the CERN Web Merge milestone Jul 10, 2023
@sonarqubecloud

Copy link
Copy Markdown

SonarCloud Quality Gate failed.    Quality Gate failed

Bug C 1 Bug
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

70.0% 70.0% Coverage
12.5% 12.5% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@pascalwengerter

Copy link
Copy Markdown
Contributor Author

Sonarcloud failure is unrelated to my changes? 🤔

@JammingBen JammingBen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

})
)

// expect scrolltoresource to have been called

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Something for a follow-up I propose 🙂

@JammingBen
JammingBen merged commit 6aabd53 into owncloud:master Jul 25, 2023
@pascalwengerter
pascalwengerter deleted the feature/7600 branch July 25, 2023 18:07
@elizavetaRa

Copy link
Copy Markdown
Contributor

@pascalwengerter @dschmidt it doesn't scroll when new folder is on another page

saw-jan pushed a commit that referenced this pull request Jul 27, 2023
* Fix #7600 && #7601

* Fix useFileActionsCreateNewFolder.spec.ts

* Fix unit tests

---------

Co-authored-by: Dominik Schmidt <[email protected]>
@JammingBen

Copy link
Copy Markdown
Contributor

@pascalwengerter @dschmidt it doesn't scroll when new folder is on another page

I've created #9494 to keep track of this. It's a bit more complex to achieve that.

AlexAndBear pushed a commit that referenced this pull request Aug 15, 2023
* Fix #7600 && #7601

* Fix useFileActionsCreateNewFolder.spec.ts

* Fix unit tests

---------

Co-authored-by: Dominik Schmidt <[email protected]>
AlexAndBear pushed a commit that referenced this pull request Dec 13, 2023
* Fix #7600 && #7601

* Fix useFileActionsCreateNewFolder.spec.ts

* Fix unit tests

---------

Co-authored-by: Dominik Schmidt <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ScrollToResource function not working as expected No scrolling to just created folder

7 participants