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

compose: Add support for full-screen compose box #17667

Merged
merged 2 commits into from Jul 7, 2021

Conversation

Signior-X
Copy link
Member

@Signior-X Signior-X commented Mar 17, 2021

Fixes #17660

  • Adds a default max-height which will facilitate scrolling.
  • Add a expansion/collapsing button for toggling full-screen view.
  • Make the CSS needed for making textarea occupy full height.
  • Find a way to handle auto-resize properly.
  • Test properly for different use cases.
  • On the close of the compose box, it should be restored to its original width.
  • Add tests once we are ready that the intended behaviour is correct. (Also make the CI tests pass)

Testing plan:
Tested manually:
Open the compose box, toggle the height using the toggler button added just below the compose area.
To check autosize doesnot interfare is that when the compose height state is true, it is destroyed as this is the way to stop all the listeners added by it (check on docs of autosize) and particularly checked for changing messages and drafts while having full size compose box.
The save and copy also doesn't not have any problems as the autosize has been destroyed.
For node tests, I think for the compose_height file some basic tests needs to be defined.

GIFs or screenshots:
The design of full height text-area currently.
image

@zulipbot zulipbot added size: L and removed size: M labels Mar 26, 2021
@Signior-X Signior-X force-pushed the compose-size branch 2 times, most recently from f587d56 to e0ed88f Compare March 26, 2021 23:32
@Signior-X Signior-X changed the title [WIP] compose: Add support for full-screen compose box compose: Add support for full-screen compose box Apr 2, 2021
@Signior-X Signior-X force-pushed the compose-size branch 4 times, most recently from e90ec35 to 00a1562 Compare April 13, 2021 20:38
@Signior-X Signior-X force-pushed the compose-size branch 2 times, most recently from f31fb92 to 0c558c3 Compare April 14, 2021 06:26
@Signior-X
Copy link
Member Author

@timabbott made the buttons with different IDs and commented above. Also rebased this, ready for another review now.

#compose-content {
height: 100%;
display: flex;
flex-flow: column;
Copy link
Sponsor Member

@timabbott timabbott Jun 16, 2021

Choose a reason for hiding this comment

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

What is the flex logic needed for?

I would hope that we can figure out how to reduce the amount of special CSS for this mode, e.g. if there are refactors we can do to the existing compose box CSS that would make these unnecessary.

Copy link
Member Author

@Signior-X Signior-X Jun 16, 2021

Choose a reason for hiding this comment

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

flex logic is needed for automatically setting the maximum height possible in the compose box. Like I give a height to #compose and then, make flex inside it. The element that needs to be stretched are given flex: 1 to automtically fill all the spaces left. and height: 100% so, that height comes down.
This makes it possible to make the height fit according to percentage of height available and parent elements.

I changed the approach for the following reasons:

  1. The alerts get handled automatically.
  2. The elements position itself, so no need to calculate height.
  3. This way also makes the height change automatically even without autosize in full screen mode if the device height is changed.

The approach of css can be simplified as start with #compose with the height the element that is fixed. Now for every element inside it, check if it is unique or have multiple children. Then look for which children needs to get stretched to obtain the left over space and give flex: 1 to it. Following this sequence, the textarea finally got the height to get maximum stretch possible and it will handle it properly.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will see for the refracter tomorrow.

Copy link
Member Author

@Signior-X Signior-X Jul 4, 2021

Choose a reason for hiding this comment

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

This is possible, clearly. Refractored accordingly.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have added another commit, so that you can see if that looks good.

@timabbott
Copy link
Sponsor Member

This looks pretty promising @Signior-X! I think we should be about ready to merge this, or at least test-deploy on chat.zulip.org once the above comments are resolved.

@Signior-X
Copy link
Member Author

@timabbott squashed the commits and commented above for the queries.

@Signior-X Signior-X force-pushed the compose-size branch 2 times, most recently from 6be2469 to da9bf7d Compare July 4, 2021 09:34
@Signior-X
Copy link
Member Author

@timabbott updated the PR accordingly, made changes accordingly. The conversations that still unresolved are above, need feedback/review on them.

@Signior-X Signior-X force-pushed the compose-size branch 2 times, most recently from 377e0b0 to 43af1db Compare July 7, 2021 10:32
@Signior-X
Copy link
Member Author

Signior-X commented Jul 7, 2021

@timabbott rebased this and now this is ready for review. Commented above for all the queries.

autosize($("#compose-textarea"));

$(".collapse_composebox_button").hide();
$(".expand_composebox_button").show();
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

I added a line in both of these functions to move focus back to the compose box, since that's almost always what you want.

Copy link
Member Author

Choose a reason for hiding this comment

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

Great!

Signior-X and others added 2 commits July 7, 2021 16:47
This commit makes a working toggler in compose_actions that adds the
compose-fullscreen class to the compose that removes the max-height
from the compose textarea and adds flex elements above so that the
height automatically adjust with the device height. This results in
making the compose box full screen sized.

The compose_height.js maintains the state of the height of the compose
box. Also, when the compose box is closed, the compose box is reset to
it's default behaviour and original height. So, everytime user need
not toggle off the compose full size and only for specific message
it is used.

It also adds destroy autosize on compose_height state change.
It destroys the autosize of textarea when the full
screen sized compose box is toggled on. And everytime when it is
turned off, it reinitialises the autosize. This also adds a
condition in autosize_textarea to only autosize when composebox
is not in full height state.

Fixes zulip#17660
This is by no means the ideal solution, since we are likely to occlude
your cursor, but it prevents the user experience from being clearly
broken.
@timabbott timabbott merged commit 98b5f01 into zulip:master Jul 7, 2021
@timabbott
Copy link
Sponsor Member

OK, I've merged this with the above changes. I think while we're thinking about this, the compose_top_right region should get its tooltips migrated from title to tippyjs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for fullscreen compose box
3 participants