Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

ASInsetLayoutSpec inside Horizontal stack layout breaks line break of text nodes #874

Closed
@smyrgl

Description

@smyrgl

It took me a while to nail down what was going on with this issue but I'll try to cover all the behaviors. I have seen this with a few components I have created but I will cover the simplest case.

This node is designed as a Horizontal stack layout with an ASDisplayNode and an ASTextNode in the horizontal stack. The layout spec looks like this:

    override func layoutSpecThatFits(constrainedSize: ASSizeRange) -> ASLayoutSpec! {
        textNode.flexShrink = true
        let insetSpec = ASInsetLayoutSpec(insets: BlockquoteInsets, child: textNode)
        sidebarNode.flexBasis = ASRelativeDimensionMakeWithPoints(2.0)
        return ASStackLayoutSpec(direction: .Horizontal,
            spacing: 0.0,
            justifyContent: .Center,
            alignItems: .Stretch,
            children: [sidebarNode, insetSpec])
    }

That produces this behavior:

brokenblockquote

Notice the lack of line breaking. It is like flexShrink isn't occurring. Looking at it in Reveal the container node that holds the textNode and owns the layout spec is sized fine but the text node itself is way oversized beyond the node bounds.

A few things to note about this:

  1. This issue ALSO occurs with ASButtonNode which has a similar layout spec.
  2. This is also occurs if you replace the ASTextNode with a wrapped UILabel ASDisplayNode.

Now here's what happens when I remove the inset. Here's the new layout spec:

    override func layoutSpecThatFits(constrainedSize: ASSizeRange) -> ASLayoutSpec! {
        textNode.spacingBefore = BlockquoteInsets.left
        textNode.spacingAfter = BlockquoteInsets.right
        textNode.flexShrink = true
        sidebarNode.flexBasis = ASRelativeDimensionMakeWithPoints(2.0)
        return ASStackLayoutSpec(direction: .Horizontal,
            spacing: 0.0,
            justifyContent: .Center,
            alignItems: .Stretch,
            children: [sidebarNode, textNode])
    }

Here's what that looks like:

simulator screen shot nov 20 2015 2 23 20 am

You should be able to easily replicate this as it seems that any Horizontal stack spec that includes an inset spec as one of its children is going to have this problem.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions