AsyncDisplayKit icon indicating copy to clipboard operation
AsyncDisplayKit copied to clipboard

ASTextNode truncationAttributedString not showing

Open tomizimobile opened this issue 10 years ago • 7 comments

I just realized that neither the truncationAttributedString or additionalTruncationMessage are showing for me anymore. It was working in 1.9.3, but stopped working in 1.9.4, and is still not working in master. I haven't tried to find an exact commit yet that breaks it though. This is easy to verify by modifying the "Kittens" example project, "KittenNode.mm" to set _textNode.maximumNumberOfLines = 5 in initialization

tomizimobile avatar Jan 04 '16 14:01 tomizimobile

@tomizimobile thanks for the report. There were definitely changes in this code. It is possible that in certain initialization orders, the ASTextKitTailTruncater doesn't work correctly. See my commit hash 99fbc97 if you want to experiment with reverting it to test, or look at the changelog for ASTextKitRenderer and ASTextNode. Most of the changes there since 1.9.3 should be possible to revert without affecting any other dependencies across AsyncDisplayKit.

I will most likely be able to investigate this by the end of the weekend, and might have time tomorrow (otherwise it's Friday night). Let me know if you happen to learn anything else about it, but you should save your time if work is demanding right now!

appleguy avatar Jan 06 '16 06:01 appleguy

There are unit test cases for truncation. We should inspect those to ensure they are functioning as desired - I'm surprised this would get through. It may be precisely that the initialization order used with the tests does not trigger this bug.

appleguy avatar Jan 06 '16 06:01 appleguy

@appleguy Thanks for the lead! I took a quick dig into it and I found that things work as expected if _truncater is set during initialization of ASTextKitRenderer. I'm not too familiar with the code, so I don't know if this has any side effects, but I'd guess it's basically negating any optimizations that were attempted. I'll have to leave reworking that to someone else, but at least for now I've got an interim fix.

tomizimobile avatar Jan 06 '16 14:01 tomizimobile

@tomizimobile could you please test this on master and let me know if it's fixed? I think it is resolved but I don't think I have a test case for this. Might be worth checking the implementation of the unit tests and adding / modifying one to include whatever code you're using to test this, because there are snapshot tests for the truncater already which are passing...but also weren't failing before!

appleguy avatar Jan 24 '16 22:01 appleguy

@appleguy I just tested on master, and it's only kind-of working. The text isn't truncated and the truncation doesn't show't, but the area where the truncation token would be responds to touches and highlights. My patch to fix this is simple, but I don't know what side effects it has: patch.diff.txt

tomizimobile avatar Jan 25 '16 14:01 tomizimobile

Should be fixed...I bumped 1.9.6 tag to include this too. Reopen or refile if seen again! Anyone who adds a test will get a <3 from me :)

appleguy avatar Jan 26 '16 03:01 appleguy

additionalTruncationMessage can not work with maximumNumberOfLines together? I mean if i set the maximumNumberOfLines, then the number of lines more than it, it will show the default truncation string "..." at the end. But if I wanna show the truncation string and additionalTruncationMessage(just like "More") together, seems not work?

abellee avatar Mar 12 '17 21:03 abellee