Repository navigation
Create new folder, navigate to page - #9548
Conversation
|
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes. |
dschmidt
left a comment
There was a problem hiding this comment.
Can you move the logic tojthe scrollToResource composable, so it can be reused?
Also my first thought :) within the |
|
@jacob-nv I think this PR lacks a changelog item linking this PR and the issue it closes :) |
|
|
||
| const scrollToResource = async (resourceId: Resource['id'], options = { forceScroll: false }) => { | ||
| if (unref(sortedItems)) { | ||
| const index = findIndex(unref(sortedItems), (item: Resource) => item.id === resourceId) |
There was a problem hiding this comment.
I'd prefer doing this lookup only in the if (!resourceElement) {...} block below and check the "current page DOM" for the fileId first?
There was a problem hiding this comment.
I guess I have an idea why, but would you mind elaborating?
There was a problem hiding this comment.
@pascalwengerter okay, I see what you mean, but if I need to scroll to element on different page, I would have to query the row again no?
Right now it's:
- Check if I'm on correct page
- If not change page
- Query DOM row
- Scroll to it
If I'm not mistaken, changing the order would then be:
- Query DOM row
- If doesn't exists, check what's the correct page and change page
- Query DOM row
- Scroll to it
There was a problem hiding this comment.
... but I would solve the whole issue a little differently, wrote it down in detail in my review
There was a problem hiding this comment.
I don't really like, that we're now sorting and paginating all files again, when it also happened in the view already.
What I thought about: make useScrollTo publish an event over the eventBus, that usePagination can consume to switch to the right page. Afterwards the actual scrolling can happen
edit:
My initial feeling was that we should just pass in the sorted/paginated resources from the useResourceViewDefaults composable - but that doesn't work when we want to switch to a newly created file/folder, where the action was triggered from CreateAndUpload - that's why I think using the eventBus might be the best option
Rewrote, but still had to move part of the useScroll login to usePagination. After publishing event and routing, useScroll is not able to query the DOM element. Or do you have better idea how to deal with? Wasn't able to sync it in a way it would execute without moving that part of logic |
|
Thanks for taking care! Yeah, we don't have a proper way to "ack" an event - maybe you could send a "navigated to page" event ... but it's probably not bad like this either and you could leave it like this. I'm about to head out, can look later or tomorrow again |
| const page = Math.ceil((index + 1) / Number(unref(perPage))) | ||
| router.push({ ...unref(route), query: { ...unref(route).query, page } }).then(() => { | ||
| eventBus.publish('app.files.navigate.scrollTo', { resourceId, forceScroll }) | ||
| }) |
There was a problem hiding this comment.
We're getting somewhere!
I'm not completely happy with this, but I played around with it and it's tricky to solve it directly through the page ref. I would like to try a few more things, but have to focus on other things for now.
If that's okay for you, I will try again tonight and if I don't find anything useful, I'm fine to have this merged tomorrow.
There was a problem hiding this comment.
I obviously didn't get to it, feel free to merge
JammingBen
left a comment
There was a problem hiding this comment.
Code LGTM, unit tests are failing though: https://drone.owncloud.com/owncloud/web/38188/9/5
useKeyboardTableNavigation (same as other keyboard actions related composables) uses useStore. |
|
SonarCloud Quality Gate failed.
|
* Create new folder, navigate to page * Revert "Create new folder, navigate to page" This reverts commit d6f6d96. * Create new folder, navigate to page - useScrollTo * Revert "Create new folder, navigate to page - useScrollTo" This reverts commit cc3fb0a. * Scroll to navigates to proper page through busEvent * Scroll to navigates - callback with busEvents * useScrollTo type fix * Pagination folder scroll, fixing eventBus path
* Create new folder, navigate to page * Revert "Create new folder, navigate to page" This reverts commit d6f6d96. * Create new folder, navigate to page - useScrollTo * Revert "Create new folder, navigate to page - useScrollTo" This reverts commit cc3fb0a. * Scroll to navigates to proper page through busEvent * Scroll to navigates - callback with busEvents * useScrollTo type fix * Pagination folder scroll, fixing eventBus path
* Create new folder, navigate to page * Revert "Create new folder, navigate to page" This reverts commit d6f6d96. * Create new folder, navigate to page - useScrollTo * Revert "Create new folder, navigate to page - useScrollTo" This reverts commit cc3fb0a. * Scroll to navigates to proper page through busEvent * Scroll to navigates - callback with busEvents * useScrollTo type fix * Pagination folder scroll, fixing eventBus path
* Create new folder, navigate to page * Revert "Create new folder, navigate to page" This reverts commit d6f6d96. * Create new folder, navigate to page - useScrollTo * Revert "Create new folder, navigate to page - useScrollTo" This reverts commit cc3fb0a. * Scroll to navigates to proper page through busEvent * Scroll to navigates - callback with busEvents * useScrollTo type fix * Pagination folder scroll, fixing eventBus path










Description
Once folder is created it's id is matched with sorted items to get page on which is located
Related Issue
Types of changes
Checklist: