Skip to content

Allow resizing Branch and Push/Pull toolbar buttons#18095

Merged
tidy-dev merged 18 commits intodesktop:developmentfrom
jpedroso:resizable-branch-dropdown-button
Sep 11, 2024
Merged

Allow resizing Branch and Push/Pull toolbar buttons#18095
tidy-dev merged 18 commits intodesktop:developmentfrom
jpedroso:resizable-branch-dropdown-button

Conversation

@jpedroso
Copy link
Contributor

@jpedroso jpedroso commented Jan 28, 2024

Closes #4569
Closes #17388

Description

Allow the user to resize the Branch and Push/Pull toolbar buttons, and their dropdown panels.

  • Both buttons have a minimum width of 230px, same as the sidebar. The max width of each button is determined by the available space in the toolbar after taking out the sidebar, minus the other button’s width. This is controlled by IConstrainedValue values and determined in updateResizableConstraints().

  • If the user-defined width of both buttons is wider than the toolbar's available width the Branch toolbar button takes precedence over the Push/Pull button. For example, when the window resizes, the Push/Pull button’s width is reduced before the Branch button’s.

  • Like the sidebar, their width can be reset to the original value (230px) with a double-click on the resizable edge.

  • The dropdown panels of each button follow the width of the button. The Branches/Pull Requests dropdown has a minimum width of 365px—the previous fixed width—to avoid the panel getting too narrow if the branches names are not long enough.

  • The empty states for the Branches and Pull Requests tabs are adjusted to the flexible width. They are now centered in the container. Decided to give them a fixed width of 365px, same as previous size, to maintain the aspect of their contents. Letting them flex to full width would make the imagery scale too much and the call to action button quite wide.

Screenshots

Walkthrough of resizing the Branch and Push/Pull toolbar buttons, Branches/PR dropdown and empty states

2024-01-28-002293.mp4

Branches dropdown empty state

2024-01-28-002297@2x

Minimum window size and maximum zoom

2024-01-28-002295@2x

Max zoom, branches dropdown empty state

2024-01-28-002296@2x

Release notes

Allow the user to resize the Branches and Push/Pull toolbar buttons.

@jpedroso jpedroso changed the title Resizable Branches and Push/Pull toolbar buttons Allow resizing Branch and Push/Pull toolbar buttons Jan 28, 2024
Comment on lines 355 to 368
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required to correctly place the dropdown below its toolbar button.

Copy link
Contributor Author

@jpedroso jpedroso Jan 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the default properties of the foldout style here might not be the best approach. I’m thinking the branch dropdown should instead provide its own foldoutStyle similar to what the sidebar dropdown has.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace the fixed width with minimum width so the branch toolbar dropdown always has at least 365px. If the toolbar button is wider than that, allow it to fill the same width.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace the fixed width and allow the branch list to fill the dropdown container (.branches-container).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Center the empty state content of the Pull Requests tab in the dropdown container, and give its imagery some spacing vertically.

Read more about the why center empty states below in the Branches tab empty state comments.

Comment on lines 2 to 3
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both for the Branches and Pull Requests empty states, I decided to keep the fixed width of 365px instead of letting the imagery, text and button expand to fill the container. Specifically, in the case of Branches tab, the Create New Branch could get uncomfortably wide. See comparison below.

Full width empty state

2024-01-28-002298@2x

Fixed width empty state

2024-01-28-002299@2x

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prevent shrinking the dropdown arrow button. Keep them always pinned to the right.

Comment on lines 36 to 42
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apply flexible width on the Branch and Push/Pull toolbar buttons.

Copy link
Contributor Author

@jpedroso jpedroso Jan 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There’s another button just below named .revert-progress also with fixed width.

&.revert-progress {
    width: 230px;
}

I believe this button should also change to width: 100%; but haven’t yet found a way to get to a state where the button shows to confirm. Any ideas welcome.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is seen when reverting a commit in a git LFS repo in which reverting a commit is very slow. Thus, this does need addressed. We can follow up with another PR since Git LFS is not a common usage and the likely hood that this would result in a negative experience is slim (worse case during loading the last toolbar button switches to 230px which could only be a clipping problem on a very small zoomed in screen). The RevertProgress toolbar button is rendered instead of the PullPushFetch so we can send the dimensions for the PullPushFetch button down to it.

@chronvas
Copy link

@jacortinas @sergiou87 Hello, can we hope to get that feature in? Any plans?

@jpedroso
Copy link
Contributor Author

@steveward @tidy-dev will this pr get any attention?

i ask because i found one layout problem with it -- the branch list grows beyond desired size when the current branch name is long enough, for which i can’t seem to find a quick fix --, but i will not put any more time into this if this just ends up stalled here.

@tidy-dev
Copy link
Contributor

@jpedroso Sorry for the delay and thank you for your patience. I cannot say a timeline, but I am interested in reviewing this. If you can find time to address the problem found that would be fantastic, (and if so, also updating this with the latest development would be awesome). Thank you for your time and patience on this.

jpedroso added 16 commits May 10, 2024 09:33
Prevents the dropdown arrow button from shrinking when the window or toolbar items are resized.
Set a new constrained value for the branch dropdown so it can only be as wide as the available space after taking the sidebar and pull fetch button widths.

The minimum size remains constant at its default width.
Instead of using a hardcoded max width of 600 and the default min width of 200, the branch dropdown resizable now uses the min and max that are provided with the constrained value.
This local var needs to reflect that some of the toolbar buttons are now resizable, and what is represents the total min width of those buttons.
Replace the inline hardcoded value with a constant defined closer the other toolbar constants.
More consistent with the `PushPullButton` type they relate to.
When there are no branches or pull requests to show, the corresponding empty states are centered on the container with a fixed width of 365px.

For the branches empty state container, the fixed width replaces `flex: 1` to prevent it from filling the container and make the Create Branch button too wide.
Prevents the branches dropdown container from becoming too narrow when branch names are not long enough.
With the empty states centered on the container, their imagery would get uncomfortably close to the top. This introduces some spacing on top and bottom to make layout more balanced.
Branch names can expand to the available width in  `.branches-list-item`.
Introduce the new property to avoid changing behavior of the existing `foldoutStyle` property.

Whereas `foldoutStyle` replaces default style entirely, `foldoutStyleOverrides` is used to add to or override the default style properties.
@jpedroso
Copy link
Contributor Author

@tidy-dev i fixed the remaining known issue, quoted below. also rebased with latest development. this is now ready for proper review.

the branch list grows beyond desired size when the current branch name is long enough, for which i can’t seem to find a quick fix

Tried many things but couldn’t fix the issue entirely in stylesheets, so the way i fixed this was to pass additional style properties for the default styles that get returned in ToolbarDropdown.getFoldoutStyle(). I decided to preserve the existing functionality of foldoutStyle since it can be used to replace the default style entirely, and instead create a new property that adds to the default style, called foldoutStyleOverrides. Tried to convey this idea in the documentation best i could.

Here’s the before and after when having a long branch name.

Before (6657053)

2024-05-10-002917@2x

After (9d7df28)

2024-05-10-002916@2x

Copy link
Contributor

@tidy-dev tidy-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jpedroso Thank you for this PR and apologies for taking so long to review.

It works beautifully. 💖

I kicked it around quite a bit and found an accessibility issue where on the min width screen and max zoom the fetch dropdown button was being clipped. Thus, I updated this to latest dev and added changes to make the branch dropdown and pull/push split the difference of the available screen width when it gets this limited size. Due to that I am going to get another engineer to review this before merging.

I also found that on max zoom and smallest windows, the branch list and pr list is clipped, but it is in production too.. just not as much so I don't think this PR should be held back because of it.

Copy link
Member

@sergiou87 sergiou87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work! 💖

@tidy-dev
Copy link
Contributor

tidy-dev commented Sep 11, 2024

Going to go ahead and merge. Tho we did discuss and decided we would like it behind a feature flag as it is such a prominent part of the app so we can have it on beta for a bit. I have got a working branch for that and will open a PR up shortly. It also addresses applying this logic to the revert commit toolbar button (which only applies to git LFS repos and only when reverting)

@tidy-dev tidy-dev merged commit 782af8d into desktop:development Sep 11, 2024
@Jay-o-Way
Copy link

@tidy-dev glad this is finally picked up.
However I believe that a "feature flag" should be used for new features, not for a simple UI improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants