-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[RNMobile] Adjust vertical margins in InnerBlock #19960
Conversation
@iamthomasbishop
It is default In e.g.
That's the way how it works but the effect you noticed is caused by reason I explained above. I hope all above make sense. The possible solution that I have in my mind are:
Keep in mind the first two solution brings more complexity to bordering style in the navigation-dow logic because depending of placement in hierarchy we should modify the margins as well to align the content Please let me know what do you think and how we should approach this according to open Group block to production. |
I'm not sure it's a blocker here. However I also think that it might be worth to add some animation in Why ? E.g. because when you nest multiple empty Group block you can loose orientation after press (the UI doesn't change) but in fact the selection does and you go deeper and deeper after each press. In other cases it will bring some nice-looking effect. Please take a look on below GIF: The structure of Blocks is presented here (nested 8 empty Group blocks):
Please observe that you do not see any effect when you select 3rd to 7th (yeah I'm pressing the block repeatedly). The UI changes only when you select the last one (because the placeholder is replaced with AppenderButton) and when you select first two (apply bordering style, breadcrumbs show the current hierarchy, navigation arrows is disabled). WDYT ? |
…locks-vertical-margin
@@ -290,6 +296,8 @@ export default compose( [ | |||
const isInnerBlockHolder = name === getGroupingBlockName(); | |||
const isRootListInnerBlockHolder = ! isSelectedBlockNested && isInnerBlockHolder; | |||
|
|||
const shouldApplyVerticalMarginStyle = ! isLastBlock && ( ( isFirstBlock && parentCount === 2 ) || parentCount > 2 ); |
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.
If I understand this correctly, this is trying to add a margin to every sibling except the last one, right?
This expression seems more complicated than it needs, if I understand each variable correctly. I see three possible cases regarding the number of children in the parent:
- There's one block (
parentCount < 2
). Then this must be the last (and first) block, so! isLastBlock === false
and the margin shouldn't apply. - There are two blocks (
parentCount == 2
). We have already set a condition to not add a margin on the last block, so theisFirstBlock
is only relevant for the other case, which will always be true: if I'm not the last of 2, I must be the first. - There are more than two blocks (
parentCount > 2
). Similarly, we've ruled out the case where we are the last block, and we want to add the margin for every other block.
So, if I'm not missing anything, the same logic should work with this simpler condition:
const shouldApplyVerticalMarginStyle = ! isLastBlock && ( ( isFirstBlock && parentCount === 2 ) || parentCount > 2 ); | |
const shouldApplyVerticalMarginStyle = ! isLastBlock; |
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.
I have check it and it's fine but after we modify isLastBlock
as below:
In previous implementation it tries to check the order base of current clientId
InnerBlocks count. Which isn't proper because we need to check the order in parent InnerBlock list.
I have checked and it seems that this flag isn't use anywhere so probably we can also prevent to pass it to component props
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.
I have also simplify passing the prop in latest commit
I think that one makes the most sense. The placeholder border "conflicts" with the nested blocks child border, and should only be used in root-level groups. |
Logically it works fine because if the group is empty it has a dashed placeholder. Considering UX I think it also looks fine. However I do not have strong opinion on that and we can try implement above solution. |
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.
It's a bit confusing navigating these many nested groups, but I think this is behaving correctly 😅
I think we also bring some refactor soon to improve UX according to this comment according to this convo One more question. Shall we remove the |
Ah, yes please, let's move that change to a different PR |
Description
PR provides additional login to adjust vertical margins when navigate through InnerBlock hierarchy.
@iamthomasbishop,
With this changes navigate inside InnerBlock becomes smoother. The spaces between block is kept with the same value. Please taka a look on presented GIFs
Please also refer to:
Issue
Related gutenberg-mobile PR
How has this been tested?
initial-html
. It provides some nested InnerBlock structureScreenshots
Types of changes
Bug fix / refactor
Checklist: