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

PopTip does not show when calling show after hide #204

Open
amohit94 opened this issue Feb 3, 2020 · 7 comments
Open

PopTip does not show when calling show after hide #204

amohit94 opened this issue Feb 3, 2020 · 7 comments

Comments

@amohit94
Copy link

amohit94 commented Feb 3, 2020

Scenario: If a PopTip is visible and we hide that Poptip and show another Poptip in the same callstack, the second Poptip is not visible.

Severity: This is important in cases where the code is such that hide and show is called from multiple places and a scenario happens when hide and show are called from the same call stack.

This happens because in the completion block for hide PopTip, its views are removed from the hierarchy. When removeAllAnimations is called, this completion block is not called immediately, but after a slight delay. In the mean time if we call show on PopTip, it adds the views in the view hierarchy and completion block for the previous hide is called after sometime removing the view from the view hierarchy.

Fix: in the completion block for animation, we should check if the animation finished and only then remove the views from the hierarchy. And when we are calling removeAllAnimations, we should ensure that the view is removed from the view hierarchy.

@andreamazz
Copy link
Owner

Hi @amohit94
can you share a bit of code to reproduce the issue?

@amohit94
Copy link
Author

amohit94 commented Feb 26, 2020

This should do the trick:

let poptip = PopTip()
poptip.showToolTip(attributedText: attributedText, popTipDirection: ToolTipManager.defaultTopTipDirection)
poptip.hide()
poptip.showToolTip(attributedText: attributedText, popTipDirection: ToolTipManager.defaultTopTipDirection)

As the previous hide was in progress when 2nd showToolTip was called, the completion block of hide removes the view added by the 2nd showToolTip.

@andreamazz
Copy link
Owner

Hi @amohit94
I'm trying this with the Demo project in the repo, but calling in sequence show, hide and show seems to be working, the result is the poptip showing, so I'm missing something.
Can you reproduce the issue in the demo project?

It is quite odd though, the hide method checks if the animation is running (if force is left at false).

@amohit94
Copy link
Author

amohit94 commented Mar 6, 2020

I'll try creating a demo project. Till then, can you try if calling hide(forced:true) reproduces the issue?

@aehlke
Copy link

aehlke commented Jul 4, 2020

Is this still an issue?

@andreamazz
Copy link
Owner

Is this still an issue?

I'm afraid so, still trying to figure out why it does that.

@hardikdarji
Copy link

Here is workaround:
popTip.hide(forced: true)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) {
popTip.show(text: message, direction: .up, maxWidth: 220, in: inView, from: tapOn)
}

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

4 participants