Skip to content

Fix Bug 1611512 - Add ability for Add Comment input to grow as you type - #1546

Merged
mathjazz merged 11 commits into
mozilla:masterfrom
abowler2:textarea-grow
Feb 3, 2020
Merged

mathjazz merged 11 commits into
mozilla:masterfrom
abowler2:textarea-grow

Conversation

@abowler2

@abowler2 abowler2 commented Jan 28, 2020 •

Copy link
Copy Markdown
Collaborator

This fix allows for the textarea in Add Comment to grow as the user types.


I have actually set up a way to grow the textarea either in a downward direction or an upward direction (similar to Slack). However, both options pose additional challenges that I have not yet found solutions for.

Downward growth (which is what is active): If there are multiple comments and the Add Comment textarea grows to the point that the outer history div begins scrolling then every keypress causes the history scroll to jump back up which is not a good experience.

Upward growth (can be activated by uncommenting the CSS in AddComent.css): This has a fluid growth action, but it does not effect the history div which means the overflow is never switched to scroll and the textarea grows up and covers the comment above it.

I have tried implementing lifecycle methods/hooks using a ref on the History ul and/or on the existing ref on the textarea to set or remember the scroll position but have not had success. The closest I came was with the downward growth and calling a function with onScroll that scrolled to the bottom, but this option disabled the ability to scroll back up.

Let me know which option is preferable (upward or downward growth) and your thoughts on how I can address the associated scrolling issue for that option. ~ Thanks

@abowler2

Copy link
Copy Markdown
Collaborator Author

Additional issue discovered is that when the user uses the shift + enter option to add a new line without submitting it is not honored when the comment renders. It shows in the database with the new lines intact but then when rendered it all runs together.

@mathjazz

mathjazz commented Feb 3, 2020

Copy link
Copy Markdown
Collaborator

Hi @abowler2, could you please resolve the conflict?

@abowler2

abowler2 commented Feb 3, 2020

Copy link
Copy Markdown
Collaborator Author

Third time's the charm....right 😉

@mathjazz mathjazz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good job! Left a few notes, nothing major.

I can't reproduce the issue with the "downward growth" scenario, though.

@abowler2

abowler2 commented Feb 3, 2020

Copy link
Copy Markdown
Collaborator Author

With the current changes the issue I was having with the downward growth is no longer present. However, it is allowing for an empty input to be submitted into the database even though there is a check for empty within the submitComment function.

@abowler2

abowler2 commented Feb 3, 2020

Copy link
Copy Markdown
Collaborator Author

Additional issue discovered is that when the user uses the shift + enter option to add a new line without submitting it is not honored when the comment renders. It shows in the database with the new lines intact but then when rendered it all runs together.

Did you have thoughts on this??

@mathjazz

mathjazz commented Feb 3, 2020

Copy link
Copy Markdown
Collaborator

Additional issue discovered is that when the user uses the shift + enter option to add a new line without submitting it is not honored when the comment renders. It shows in the database with the new lines intact but then when rendered it all runs together.

Did you have thoughts on this??

We should use white-space: pre-wrap; when rendering comments.

OTOH, we should use white-space: nowrap; in the comment author element to prevent wrapping it into multiple lines.

Please also revert the changes in Translation.js and views.py when the PR is complete, so that the comments functionality remains disabled.

@mathjazz mathjazz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Great work!

@mathjazz
mathjazz merged commit b33dcbf into mozilla:master Feb 3, 2020
@abowler2
abowler2 deleted the textarea-grow branch February 3, 2020 23:27
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.

2 participants