Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

[NEW] Message character limit feature #443

Conversation

ogustavo-pereira
Copy link
Contributor

@ogustavo-pereira ogustavo-pereira commented Jul 9, 2020

Depends on RocketChat/Rocket.Chat#18261

The main goal of this PR is to add functionality to add character limit for messages.

ezgif-4-80d563ac6618

#416

* adding new component ReminderCharacters on Footer

* update function shouldComponentUpdate in Composer

* adding config.settings.limitTextLength in screenProps
* added limitTextLength validation if null
@renatobecker
Copy link
Contributor

Hey @oguhpereira thanks for contributing, It seems to be a very nice feature!

I have two points to discuss here before we review/merge your code:

  • We need the design implemented on the storybook first;
  • We need to discuss the design you implemented with our design team, so please share a new gif or a video demo of this feature with higher quality, it's hard to see it on the gif you shared.

I'll be waiting for some news.

Thanks.

@ogustavo-pereira
Copy link
Contributor Author

Hi @renatobecker this is the original video.

I went to add the storybook but there seems to be a problem of compatibility of the preact with the version that is in the package.json

@renatobecker
Copy link
Contributor

Hi @renatobecker this is the original video.

I went to add the storybook but there seems to be a problem of compatibility of the preact with the version that is in the package.json

I just watched your video, I noticed that even there is a message length limit, you're allowing the user to type new characters. why?

@ogustavo-pereira
Copy link
Contributor Author

@renatobecker I based it on twitter's UX. I don't prevent the user from entering the message, just block the sending. I'm trying not to create a bad experience when I exceed the character limit. Therefore, even if the user types a message larger than expected, he can adapt to fit the limit.

@renatobecker
Copy link
Contributor

@renatobecker I based it on twitter's UX. I don't prevent the user from entering the message, just block the sending. I'm trying not to create a bad experience when I exceed the character limit. Therefore, even if the user types a message larger than expected, he can adapt to fit the limit.

So, I see two points here:

  • if you are just blocking the sending, why do you display the message length limit?
  • do you think it's a good UX allowing the users to type hundred words and then tell them are not allowed to send the message because the limit has been reached?

Sry, this doesn't make sense to me.

@ogustavo-pereira
Copy link
Contributor Author

if you are just blocking the sending, why do you display the message length limit?
do you think it's a good UX allowing the users to type hundred words and then tell them are not allowed to send the message because the limit has been reached?

  • For the user to see how many characters passed
  • In my opinion, it is a good UX to allow the user to type as much as he wants and then review and delete the excess until it fits the limit

@renatobecker
Copy link
Contributor

if you are just blocking the sending, why do you display the message length limit?
do you think it's a good UX allowing the users to type hundred words and then tell them are not allowed to send the message because the limit has been reached?

  • For the user to see how many characters passed
  • In my opinion, it is a good UX to allow the user to type as much as he wants and then review and delete the excess until it fits the limit

I see.
I understand that for Twitter it may make sense, but here the users aren't blog posting, they're sending messages in a row, which means this isn't the UX our users are expecting for.
If you're willing to implement the feature according to our UI/UX, I will be able to review it.
In addition, there is a conflict in a file, it must be fixed too.

Thanks.

* Removing visual effects when exceeding message limit
* Adding write block when passing the character limit value
@ogustavo-pereira
Copy link
Contributor Author

If you're willing to implement the feature according to our UI/UX, I will be able to review it.

@renatobecker, I removed the changes commented above, added a lock to continue typing. Check on video

@renatobecker
Copy link
Contributor

If you're willing to implement the feature according to our UI/UX, I will be able to review it.

@renatobecker, I removed the changes commented above, added a lock to continue typing. Check on video

Ohh that's awesome!
@oguhpereira what do you think about highlighting the character counter when the limit is reached?
Think about it..

* Creating class footer__remainder-alert
* Changing to class footer__remainder-alert when textLength is equal character limit
@ogustavo-pereira
Copy link
Contributor Author

@renatobecker When text reaches the limit it changes to $color-red. Check on video

@@ -182,6 +182,7 @@ export class App extends Component {
expanded,
alerts,
modal,
config,
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need this here, the StoreConsumer is propagating the config prop to the App components.

@@ -204,6 +205,7 @@ export class App extends Component {
onOpenWindow: this.handleOpenWindow,
onDismissAlert: this.handleDismissAlert,
dismissNotification: this.dismissNotification,
limitTextLength: config.settings.limitTextLength,
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need this here, the StoreConsumer is propagating the config prop to the App components.
You need to extract the prop value here:
https://github.com/RocketChat/Rocket.Chat.Livechat/blob/develop/src/routes/Chat/container.js#L338

And then pass it through the components.

@@ -41,6 +41,16 @@

@include pressable-button(2px);
}

&__remainder, &__remainder-alert {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
&__remainder, &__remainder-alert {
&__remainder {
margin-left: 10px;
min-width: 100px;
font-weight: bold;
&--highlight {
color: $color-red;
transition: color .2s;
}
}

@@ -43,3 +43,13 @@ export const FooterOptions = ({ children }) => (
{children}
</PopoverMenu>
);


export const ReminderCharacters = ({ className, style = {}, textLenght, limitTextLength }) => (
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
export const ReminderCharacters = ({ className, style = {}, textLenght, limitTextLength }) => (
export const CharCounter = ({ className, style = {}, textLength, limitTextLength }) => (
<span
className={createClassName(styles, 'footer__remainder', { highlight: textLength === limitTextLength }, [className])}
style={style}
>
{textLength} / {limitTextLength}
</span>
);

@@ -2,7 +2,7 @@ import { Component } from 'preact';

import { Composer, ComposerAction, ComposerActions } from '../../components/Composer';
import { FilesDropTarget } from '../../components/FilesDropTarget';
import { FooterOptions } from '../../components/Footer';
import { FooterOptions, ReminderCharacters } from '../../components/Footer';
Copy link
Contributor

@renatobecker renatobecker Jul 27, 2020

Choose a reason for hiding this comment

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

Suggested change
import { FooterOptions, ReminderCharacters } from '../../components/Footer';
import { FooterOptions, CharCounter } from '../../components/Footer';

@@ -162,14 +172,15 @@ export default class Chat extends Component {
<ComposerAction onClick={this.handleUploadClick}>
<PlusIcon width={20} />
</ComposerAction>
)}
)}1
Copy link
Contributor

Choose a reason for hiding this comment

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

??

Copy link
Contributor

Choose a reason for hiding this comment

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

@oguhpereira what's the reason to add the 1 here?
I didn't get it, was it a mistake?
I noticed you left the 1 here after my review.

* Changing component name to CharCounter
* Changing alert to hilight
@@ -162,14 +172,15 @@ export default class Chat extends Component {
<ComposerAction onClick={this.handleUploadClick}>
<PlusIcon width={20} />
</ComposerAction>
)}
)}1
Copy link
Contributor

Choose a reason for hiding this comment

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

@oguhpereira what's the reason to add the 1 here?
I didn't get it, was it a mistake?
I noticed you left the 1 here after my review.

@renatobecker
Copy link
Contributor

renatobecker commented Jul 29, 2020

@oguhpereira the storybook is okay now, please pull the last changes from the develop branch and try again.
After that, you'll be able to add the new component to the storybook.

@ogustavo-pereira
Copy link
Contributor Author

@renatobecker I removed the number 1, it is not part of the logic, I also added the storybook

@renatobecker renatobecker changed the title [NEW] Setting a character limit [NEW] Message character limit feature Aug 3, 2020
@ggazzo ggazzo mentioned this pull request Aug 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants