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

SkeletonView removes text from labels after hideSkeleton() called #75

Closed
tguidon opened this issue Jun 28, 2018 · 10 comments
Closed

SkeletonView removes text from labels after hideSkeleton() called #75

tguidon opened this issue Jun 28, 2018 · 10 comments

Comments

@tguidon
Copy link

tguidon commented Jun 28, 2018

⚠️ Please fill out this template when filing an issue.

🙏🏼 Please check if it already exists other issue related with yours.

What did you do?

I have an array of views I show the SkeletonView on

let animation = SkeletonAnimationBuilder().makeSlidingAnimation(withDirection: .leftRight)
skeletonViews.forEach { $0.showAnimatedGradientSkeleton(animation: animation) }

Once my data is loaded I call

skeletonViews.forEach { $0.hideSkeleton() }

I have also run the same scenario with each show and hide call directly on the view/label.

What did you expect to happen?

My labels to be filled in with their original text.

What happened instead?

The text is removed and the labels are empty.

Steps to reproduce the behavior

Create labels in Interface Builder and set their text in IB. Show the gradient skeleton view and then hide it

SkeletonView Environment

SkeletonView version: 1.2.1
Xcode version: 9.4.1
Swift version: 4.1

@aureliendelrue
Copy link

Same problem for me

@tguidon
Copy link
Author

tguidon commented Jul 12, 2018

Upon further digging into tickets and PRs it looks like this might be the intended action.

Would be nice to have the option to revert back to the old text.

@tendai-moffatt
Copy link

tendai-moffatt commented Jul 12, 2018

I believe it is a bug in Recoverable.swift line 43:
text = text == "" || forced ? viewState?.text : text

The text is always nil at it is set to this in PrepareForSkeletonProtocol.swift line 17:

extension UILabel: PrepareForSkeleton {
    func prepareViewForSkeleton() {
        text = nil
        resignFirstResponder()
    }
}

Changing the check in Recoverable.swift to check for a nil OR empty string fixes the bug:
text = text == nil || text == "" || forced ? viewState?.text : text

I will fork and put in a PR now!

@tendai-moffatt
Copy link

I've just noticed that the bug was actually fixed a couple of weeks ago:
ff42bd0

but as there hasn't been a tagged release for over a month, the changes won't get pulled in with Carthage/Pods

@dmhts
Copy link

dmhts commented Jul 12, 2018

@Juanpe please tag a new release, it is a pretty critical bugfix. Thanks.

@Juanpe
Copy link
Owner

Juanpe commented Aug 23, 2019

This bug is fixed in version 1.8 :)

@Juanpe Juanpe closed this as completed Aug 23, 2019
@n1schal
Copy link

n1schal commented Dec 17, 2019

@Juanpe Hey, sorry for commenting on a closed issue, but I'm on SkeletonView 1.8.2 and a couple of my Labels are being hidden. Upon logging their texts, it does print the correct text but the labels aren't shown. Even tried label.isHidden = false but still can't get them to show.

@daviskoh-hiatus
Copy link

still an issue in 1.8.6

@lukeirvin
Copy link

I believe this is still an issue in 1.8.7 as well

@pnzr00t
Copy link

pnzr00t commented May 20, 2024

Hm probably in 1.30.4 not working too.

1.31.0 - Same problem

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

9 participants