-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Spacer: Use layout context to work out whether or not Spacer should be horizontal in the Row block #39743
Conversation
c990522
to
ca5c57f
Compare
Size Change: +125 B (0%) Total Size: 1.22 MB
ℹ️ View Unchanged
|
It may or may not be an issue, but if you add a Spacer to a Row block it works as expected, but if you then transform it to a Group the Spacer seems to disappear as the height is set to 0px: spacer.mp4 |
Oh, good catch @glendaviesnz, thanks for testing! I wonder what the expected behaviour would be here. Do you think something like if the orientation is switched, then we convert the current width value to height? I wonder if users would be more likely to expect the value to be converted, or for it to be effectively removed via the |
I would be inclined to try this for starters |
Thanks, if I don't get a chance today, I'll have a play with that tomorrow! |
I remember @tellthemachines worked on a similar problem in the Navigation block, so will probably be interested in this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing this one @andrewserong 👍
It tests pretty well for me although I did encounter the same minor issue @glendaviesnz noted.
Along those same lines, after having set a spacer's width or height in one context and then dragging or grouping it into a new context, it surprised me a bit the retention of the "unused" value.
I'm not sure what the better behaviour is but it could be something to consider while addressing the zero height issue raised previously.
Screen.Recording.2022-03-28.at.6.25.01.pm.mp4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the items mentioned above, this tested as expected for me. I was able to insert a space in the row block and adjust it horizontally. Inserting a space between two paragraph blocks continued to work vertically.
One slight annoyance is that the [+] button often obscures the handle for resizing a horizontal spacer.
@@ -17,6 +17,10 @@ | |||
"enum": [ "all", "insert", false ] | |||
} | |||
}, | |||
"providesContext": { | |||
"layout": "layout", | |||
"orientation": "orientation" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The block doesn't have an orientation
attribute. Also I'm wondering if this is something we should consider adding in the layout
support by default and not adhoc in Group block. Do you know other similar use cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I've had a go in 3ac8f3c at moving the providesContext
to the layout block support instead. I think a good case could be made for passing it down as context in all cases where the layout support is opted into, particularly given that child blocks still need to explicitly opt-in to allow accessing that context.
ca5c57f
to
3ac8f3c
Compare
Just dusting this PR off: I've just converted this back to Draft while I explore the idea of passing the Layout context down at the block support level, instead of having to have blocks like Group explicitly provide the context in I haven't tested this with Native yet (I think I'll need to do some updates there), so I'll continue chipping away tomorrow. |
…ntal when a default orientation value is not available
3ac8f3c
to
b69a81d
Compare
Update: I'm about to close my laptop and go AFK, so just writing a little update of where this PR is at in case anyone would like to pick it up. Here's the status:
So, it might be better to defer the React Native side of things to a separate PR that also coincides with adding proper support for the Row variation in native. Note: if anyone else is struggling to run React Native locally on an M1 laptop, I could get it working if I first follow the steps in the React Native docs for M1 laptops, and then update the
Anyway, hopefully some of that info will help anyone else who might like to look at this — if anyone wants to have a go at finishing off this PR, feel free to jump in! Otherwise, I'm happy to pick it up again when I'm back in a few weeks. Thanks! 👋 |
This PR is quite stale now, and since there is other work that will be explored for widths in the row block which also relates to layout context at the child-of-layout-block level (#44467), I'll close this PR out for now. |
What?
Fixes #36197
Update the Spacer block to look at
layout
data to infer orientation if no default orientation is available. This primarily addresses an issue when the Spacer block is a child of the Row block.Why?
The Row block does not set a
horizontal
orientation explicitly — its orientation is implicit.How?
layout
attribute to the context that's provided for blocks that opt-in to the layout supportTesting Instructions
Screenshots or screencast