Skip to content

Dynamic constraints for resizable components - #13439

Merged
niik merged 22 commits into
developmentfrom
so-much-room-for-activities
Dec 7, 2021
Merged

niik merged 22 commits into
developmentfrom
so-much-room-for-activities

Conversation

@niik

@niik niik commented Dec 3, 2021 •

Copy link
Copy Markdown
Member

Closes #2745

Description

Since the very first versions of GitHub Desktop we've enforced a max width for our resizable components (the changes/history list, and the file list in the stashed changes view and in the selected commit view).

These constraints were put in place to ensure that you couldn't resize these components to a point where you could no longer use parts of the UI because they were now being rendered outside of the window bounds.

The constraints we set where based on running the app in the minimum window size such that it wouldn't be possible to maximize the app, resize the panes, and then restore the window size and find yourself in a situation where parts of the UI were being rendered outside of the window bounds.

This was always intended to be a temporary solution until we could get around to implementing a dynamic max-width that got recalculated based on the layout of the app and the window size (see #1588 (comment)). There's been several attempts by community contributors to address this issue that we've unfortunately had to reject since they focused on removing/increasing the constraints, not making the constraints themselves adapt to the window dimensions.

In this PR we're making the resizable panes remember their "desired" value and dynamically calculate their max width depending on the width of other resizable panes that affect the available space and the windows dimensions while making sure the the UI is usable.

By keeping track of the desired width we can support resizing the application in a consistent way where maximizing the app, resizing the panes then restoring its size will cause the panes to shrink to fit their constraints but (unless modified again) they will inflate to their desired size again once the app is maximized again.

Screenshots

image
image
image

Release notes

Notes:

image


function constrain(
value: IConstrainedValue | number,
min = -Infinity,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TIL: You can specify infinity as a number 🤯

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's the negative infinity that cracks me up! 😄

@tidy-dev tidy-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✨ Looks great and tested it out and feels oddly freeing 😸

@niik
niik merged commit 4915a67 into development Dec 7, 2021
@niik
niik deleted the so-much-room-for-activities branch December 7, 2021 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Column widths are limited — would love to remove those widths

2 participants