{"action":"closed","issue":{"url":"https://api.github.com/repos/facebookarchive/AsyncDisplayKit/issues/3128","repository_url":"https://api.github.com/repos/facebookarchive/AsyncDisplayKit","labels_url":"https://api.github.com/repos/facebookarchive/AsyncDisplayKit/issues/3128/labels{/name}","comments_url":"https://api.github.com/repos/facebookarchive/AsyncDisplayKit/issues/3128/comments","events_url":"https://api.github.com/repos/facebookarchive/AsyncDisplayKit/issues/3128/events","html_url":"https://github.com/facebookarchive/AsyncDisplayKit/issues/3128","id":211345446,"number":3128,"title":"[ASButtonNode / ASTextNode] Incorrect maximum number of lines with line spacing","user":{"login":"Kaspik","id":7204168,"avatar_url":"https://avatars0.githubusercontent.com/u/7204168?v=3","gravatar_id":"","url":"https://api.github.com/users/Kaspik","html_url":"https://github.com/Kaspik","followers_url":"https://api.github.com/users/Kaspik/followers","following_url":"https://api.github.com/users/Kaspik/following{/other_user}","gists_url":"https://api.github.com/users/Kaspik/gists{/gist_id}","starred_url":"https://api.github.com/users/Kaspik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kaspik/subscriptions","organizations_url":"https://api.github.com/users/Kaspik/orgs","repos_url":"https://api.github.com/users/Kaspik/repos","events_url":"https://api.github.com/users/Kaspik/events{/privacy}","received_events_url":"https://api.github.com/users/Kaspik/received_events","type":"User","site_admin":false},"labels":[{"id":337808363,"url":"https://api.github.com/repos/facebookarchive/AsyncDisplayKit/labels/ASTextNode","name":"ASTextNode","color":"d4c5f9","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2017-03-02T10:11:59Z","updated_at":"2017-05-01T23:48:14Z","closed_at":"2017-05-01T23:48:14Z","body":"AsyncDisplayKit version: 2.2\r\nAble to reproduce: 100%\r\n\r\nI have node (it's overlay of another, but it's not important). This node includes two `ASButtonNode` nodes.\r\n\r\nHere is setup of the nodes:\r\n```obj-c\r\n_studentNamesButtonNode = [[ASButtonNode alloc] init];\r\n        _studentNamesButtonNode.backgroundColor = [UIColor dojoWhite];\r\n        _studentNamesButtonNode.cornerRadius = CORNER_RADIUS;\r\n        _studentNamesButtonNode.enabled = NO;\r\n        _studentNamesButtonNode.contentHorizontalAlignment = ASHorizontalAlignmentLeft;\r\n        _studentNamesButtonNode.titleNode.maximumNumberOfLines = 1;\r\n        _studentNamesButtonNode.titleNode.truncationMode = NSLineBreakByTruncatingTail;\r\n        _studentNamesButtonNode.titleNode.textContainerInset = UIEdgeInsetsMake(8.0f, 8.0f, 8.0f, 8.0);\r\n        _studentNamesButtonNode.style.flexShrink = 1.0f;\r\n        \r\n        [_studentNamesButtonNode setAttributedTitle:[NSAttributedString dojoString:viewModel.pendingStudentNames emphasis:CDUFontEmphasisBold fontSize:CDUFontSizeMedium color:[UIColor dojoPurple]] forState:UIControlStateDisabled];\r\n        \r\n        _captionButtonNode = [[ASButtonNode alloc] init];\r\n        _captionButtonNode.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.8f];\r\n        _captionButtonNode.enabled = NO;\r\n        _captionButtonNode.contentHorizontalAlignment = ASHorizontalAlignmentLeft;\r\n        _captionButtonNode.contentVerticalAlignment = ASVerticalAlignmentCenter;\r\n        _captionButtonNode.titleNode.maximumNumberOfLines = 4;\r\n        _captionButtonNode.titleNode.textContainerInset = UIEdgeInsetsMake(8.0f, 12.0f, 8.0f, 12.0f);\r\n        _captionButtonNode.style.flexGrow = 1.0f;\r\n        \r\n        [_captionButtonNode setAttributedTitle:[NSAttributedString dojoString:viewModel.bodyString emphasis:CDUFontEmphasisNone fontSize:CDUFontSizeMedium color:[UIColor dojoWhite]] forState:UIControlStateDisabled];\r\n\r\n        self.automaticallyManagesSubnodes = YES;\r\n```\r\n\r\nFirst node is okay - there is maximum number of lines 1 and node calculation is okay.\r\nSecond node is problematic - when there is more lines than 2, it doesn't calculate correctly - via screenshot:\r\n![simulator screen shot 2 mar 2017 11 09 44](https://cloud.githubusercontent.com/assets/7204168/23502632/ca653bb0-ff38-11e6-8fa7-cc5bc89b7456.png)\r\n\r\nAs you can see from the code - number of lines should be 4, but it's 3 and then big space.\r\n\r\nHere is how we are doing `layoutSpecThatFits`:\r\n```obj-c\r\n- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize {\r\n    \r\n    ASInsetLayoutSpec *studentNamesStackLayoutSpec = [self studentNamesInsetSpec];\r\n    \r\n    ASStackLayoutSpec *verticalLayoutSpec = [ASStackLayoutSpec verticalStackLayoutSpec];\r\n    verticalLayoutSpec.alignItems = ASStackLayoutAlignItemsStretch;\r\n    verticalLayoutSpec.style.flexShrink = 1.0f;\r\n    verticalLayoutSpec.spacing = 0.0f;\r\n    \r\n    if (self.viewModel.bodyString.length > 0) {\r\n        \r\n        [verticalLayoutSpec setChildren:@[studentNamesStackLayoutSpec, self.captionButtonNode]];\r\n    } else {\r\n        \r\n        [verticalLayoutSpec setChildren:@[studentNamesStackLayoutSpec]];\r\n    }\r\n    return verticalLayoutSpec;\r\n}\r\n\r\n- (ASInsetLayoutSpec *)studentNamesInsetSpec {\r\n    \r\n    ASStackLayoutSpec *horizontalLayoutSpec = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal spacing:0.0f justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsStart children:@[self.studentNamesButtonNode]];\r\n    \r\n    ASInsetLayoutSpec *insetSpec = [ASInsetLayoutSpec insetLayoutSpecWithInsets:UIEdgeInsetsMake(0.0f, 12.0f, 12.0f, 12.0f) child:horizontalLayoutSpec];\r\n    return insetSpec;\r\n}\r\n```\r\n\r\nI think the problem is calculation together with container insets + attributed title."}}
{"actor":{"display_login":"garrettmoon"}}