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

(H/V)Stack doesn't align elements correctly if used with a Spacer #441

Open
Joannis opened this issue Aug 18, 2021 · 4 comments
Open

(H/V)Stack doesn't align elements correctly if used with a Spacer #441

Joannis opened this issue Aug 18, 2021 · 4 comments
Assignees
Labels
bug Something isn't working Hacktoberfest Issues that are ready for Hacktoberfest contributors to work on.

Comments

@Joannis
Copy link
Contributor

Joannis commented Aug 18, 2021

Describe the bug
When using a (V/H)Stack with a spacer inbetween two elements, the elements should take up their natural size. Instead, they're taking up an equal third of the space, and are aligned at their natural 'start'. Which is top for VStack and left for HStack.

To Reproduce

struct ContentView: View {
    var body: some View {
        HStack {
            Text("HI")
            Spacer()
            Text("HI")
        }
    }
}

Expected behavior
The second "HI" should be aligned to the far right.

Screenshots


Desktop (please complete the following information):

  • OS: macOS
  • Browser Safari
  • Version of the browser 15.0 (17612.1.24.1.4)
  • Version of Tokamak [e.g. 0.6.1]
@Joannis Joannis added the bug Something isn't working label Aug 18, 2021
@carson-katri
Copy link
Member

This is probably because we started using grid for stacks instead of flex box because of the gap property. However, I think flexbox supports the gap property in most browsers, so could we maybe switch back?

@Joannis
Copy link
Contributor Author

Joannis commented Aug 18, 2021

Correct, it's due to grids. But I'm not sure what a good alternative is.

@carson-katri
Copy link
Member

carson-katri commented Aug 18, 2021

Here's is the browser support for flexbox gap for reference: https://caniuse.com/flexbox-gap

@MaxDesiatov MaxDesiatov added the Hacktoberfest Issues that are ready for Hacktoberfest contributors to work on. label Oct 1, 2021
@SwiftCoderJoe
Copy link

flexbox-gap looks good enough to me.

The only major browsers based on relative userbase size that I could see being a problem are the older Safari browsers (Both desktop and iOS), but considering Apple platforms have a history of having fast adoption of newer OS versions, I wouldn't be too worried about those user-groups staying around long.

I'd vote to switch back to flex considering how high the standard adoption is and how often aligning things using spacer() can be useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Hacktoberfest Issues that are ready for Hacktoberfest contributors to work on.
Development

No branches or pull requests

4 participants