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

There is an issue that accidentally gets stuck and cannot keep clicking other tab item #652

Open
zllarry opened this issue Dec 9, 2022 · 4 comments

Comments

@zllarry
Copy link

zllarry commented Dec 9, 2022

I print some log, Looking forward to your reply:
$$$$$: 01 didSelectItem pagingItem = DuPagingTitleIndexItem(index: 13, title: "skateboard"), state = selected(pagingItem: DUCommunity.DuPagingTitleIndexItem(index: 12, title: "Exercise and fitness"))

$$$$$ 02 select pagingItem = DuPagingTitleIndexItem(index: 13, title: "skateboard"), direction = forward(sibling: true), animated = true

$$$$$ 03-1 selectNext animated = true this step call selectNext(:), and goon calling scrollForward(), There is no print next
“$$$$$: 04 willScrollToItem state = ...”, It's to say that be not calling setContentOffset when "call scrollForward", the state == .scrolling cannot be changed, And then click anyway, right,slect(index:) come into "defult: break"
func selectNext(animated: Bool) {
if animated {
resetState()
delegate?.scrollForward()
} else {
...
}
}
and then call scrollForward()
func scrollForward() {
if isRightToLeft {
switch manager.state {
case .first, .center:
setContentOffset(.zero, animated: true)
case .single, .empty, .last:
break
}
} else {
switch manager.state {
case .first:
setContentOffset(pageSize, animated: true)
case .center:
setContentOffset(pageSize * 2, animated: true)
case .single, .empty, .last:
break
}
}
}

@rechsteiner
Copy link
Owner

Hi @zllarry! Do you have any ways of reproducing this issue?

@jaceklapinski
Copy link

Hello @rechsteiner

I think i know how to do this, because i am facing similar issue right now.

Below flow to do reproduce:

  1. Add two view controllers into PagingViewController
  2. Go into second vc
  3. Call something to update second vc title ( self.title = "new title" ) - title need to be different then initial title
  4. Call pagingViewController.reloadMenu()
  5. Menu indicator will switch to first vc and all will be locked

I Can send you movie in private message if you need, just let me know.

Best !

@rechsteiner
Copy link
Owner

Hi @jaceklapinski! Sorry for the late response. Are you using PagingIndexItem? If you want to change the title of the menu item, but keep the same identity, you probably need to use a custom PagingItem. PagingIndexItem uses the title as part of its Hashable implementation, which means it will be considered a new item when changing the title. This is why the menu will switch to the first view controller. If you were to provide a custom PagingItem with stable identifiers, it should work. You can take a look at the Icons example here for creating custom items.

That said, I think Parchment should handle reloadMenu a bit better here. When calling reloadMenu when the current paging item is removed (because the identity changed), we should probably remove the current content view as well. The way to achieve this today is to use reloadData, but I think it makes sense that reloadMenu does the same.

@jaceklapinski
Copy link

jaceklapinski commented Feb 21, 2024

@rechsteiner i think i know where the problem is right now. And my previous assumptions was wrong

If viewController with Parchment is not visible for example I am on different tab in TabViewController and I am trying to change Parchment selected index using for example

func select(indexPath: IndexPath, animated: Bool)

It will block change pages. I made a small debug session and it looks like that problem is here:

Screenshot 2024-02-21 at 08 43 28

If Parchment is not visible and user try to change selected page line 67 is triggered then when I get back to Parchment and tap on menu line 91 block changes ...

Best !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants