Skip to content

Commit

Permalink
Merge pull request #184 from GetStream/vishal/bug-fixes
Browse files Browse the repository at this point in the history
Translation fix and additionalTextareaProps prop support
  • Loading branch information
vishalnarkhede authored Mar 26, 2020
2 parents 7de6db5 + a6719bb commit 45944ce
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/components/AutoCompleteTextarea/Textarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ class ReactTextareaAutocomplete extends React.Component {
'handleSubmit',
'replaceWord',
'grow',
'additionalTextareaProps',
];

// eslint-disable-next-line
Expand Down Expand Up @@ -774,6 +775,7 @@ class ReactTextareaAutocomplete extends React.Component {
onFocus={this.props.onFocus}
value={value}
style={style}
{...this.props.additionalTextareaProps}
/>
</div>
);
Expand Down
5 changes: 5 additions & 0 deletions src/components/ChatAutoComplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export class ChatAutoComplete extends PureComponent {
commands: PropTypes.array,
/** Listener for onfocus event on textarea */
onFocus: PropTypes.object,
/**
* Any additional attrubutes that you may want to add for underlying HTML textarea element.
*/
additionalTextareaProps: PropTypes.object,
};

static defaultProps = {
Expand Down Expand Up @@ -175,6 +179,7 @@ export class ChatAutoComplete extends PureComponent {
value={this.props.value}
grow={this.props.grow}
disabled={this.props.disabled}
additionalTextareaProps={this.props.additionalTextareaProps}
/>
);
}
Expand Down
5 changes: 5 additions & 0 deletions src/components/EditMessageForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ class EditMessageForm extends React.Component {
maxNumberOfFiles: PropTypes.number,
/** @see See [channel context](https://getstream.github.io/stream-chat-react/#channel) doc */
acceptedFiles: PropTypes.object,
/**
* Any additional attrubutes that you may want to add for underlying HTML textarea element.
*/
additionalTextareaProps: PropTypes.object,
};

static defaultProps = {
Expand Down Expand Up @@ -179,6 +183,7 @@ class EditMessageForm extends React.Component {
maxRows={this.props.maxRows}
onPaste={this.props.onPaste}
grow={this.props.grow}
additionalTextareaProps={this.props.additionalTextareaProps}
/>
<div className="str-chat__message-team-form-footer">
<div className="str-chat__edit-message-form-options">
Expand Down
7 changes: 6 additions & 1 deletion src/components/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import deepequal from 'deep-equal';
import { MessageSimple } from './MessageSimple';
import { Attachment } from './Attachment';
import { MESSAGE_ACTIONS } from '../utils';
import { withTranslationContext } from '../context';

/**
* Message - A high level component which implements all the logic required for a message.
Expand All @@ -13,7 +14,7 @@ import { MESSAGE_ACTIONS } from '../utils';
* @example ./docs/Message.md
* @extends Component
*/
export class Message extends Component {
class Message extends Component {
constructor(props) {
super(props);
this.state = {
Expand Down Expand Up @@ -499,3 +500,7 @@ export class Message extends Component {
);
}
}

Message = withTranslationContext(Message);

export { Message };
11 changes: 11 additions & 0 deletions src/components/MessageInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ class MessageInput extends PureComponent {
* Defaults to and accepts same props as: [SendButton](https://getstream.github.io/stream-chat-react/#sendbutton)
* */
SendButton: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
/**
* Any additional attrubutes that you may want to add for underlying HTML textarea element.
* e.g.
* <MessageInput
* additionalTextareaProps={{
* maxLength: 10,
* }}
* />
*/
additionalTextareaProps: PropTypes.object,
};

static defaultProps = {
Expand All @@ -139,6 +149,7 @@ class MessageInput extends PureComponent {
maxRows: 10,
Input: MessageInputLarge,
SendButton,
additionalTextareaProps: {},
};

componentDidMount() {
Expand Down
5 changes: 5 additions & 0 deletions src/components/MessageInputFlat.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ class MessageInputFlat extends PureComponent {
* Defaults to and accepts same props as: [SendButton](https://getstream.github.io/stream-chat-react/#sendbutton)
* */
SendButton: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
/**
* Any additional attrubutes that you may want to add for underlying HTML textarea element.
*/
additionalTextareaProps: PropTypes.object,
};

static defaultProps = {
Expand Down Expand Up @@ -175,6 +179,7 @@ class MessageInputFlat extends PureComponent {
grow={this.props.grow}
onFocus={this.props.onFocus}
disabled={this.props.disabled}
additionalTextareaProps={this.props.additionalTextareaProps}
/>

<span
Expand Down
5 changes: 5 additions & 0 deletions src/components/MessageInputLarge.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ class MessageInputLarge extends PureComponent {
* Defaults to and accepts same props as: [SendButton](https://getstream.github.io/stream-chat-react/#sendbutton)
* */
SendButton: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
/**
* Any additional attrubutes that you may want to add for underlying HTML textarea element.
*/
additionalTextareaProps: PropTypes.object,
};

renderUploads = () => (
Expand Down Expand Up @@ -203,6 +207,7 @@ class MessageInputLarge extends PureComponent {
onPaste={this.props.onPaste}
grow={this.props.grow}
disabled={this.props.disabled}
additionalTextareaProps={this.props.additionalTextareaProps}
/>

<span
Expand Down
5 changes: 5 additions & 0 deletions src/components/MessageInputSmall.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ class MessageInputSmall extends PureComponent {
* Defaults to and accepts same props as: [SendButton](https://getstream.github.io/stream-chat-react/#sendbutton)
* */
SendButton: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
/**
* Any additional attrubutes that you may want to add for underlying HTML textarea element.
*/
additionalTextareaProps: PropTypes.object,
};

renderUploads = () => (
Expand Down Expand Up @@ -176,6 +180,7 @@ class MessageInputSmall extends PureComponent {
onPaste={this.props.onPaste}
grow={this.props.grow}
disabled={this.props.disabled}
additionalTextareaProps={this.props.additionalTextareaProps}
/>

<span
Expand Down
11 changes: 11 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,16 @@ export interface MessageInputProps {

/** Completely override the submit handler (advanced usage only) */
overrideSubmitHandler?(message: object, channelCid: string): void;
/**
* Any additional attrubutes that you may want to add for underlying HTML textarea element.
* e.g.
* <MessageInput
* additionalTextareaProps={{
* maxLength: 10,
* }}
* />
*/
additionalTextareaProps: object;
}

export type ImageUpload = {
Expand Down Expand Up @@ -655,6 +665,7 @@ export interface ChatAutoCompleteProps {
commands: Client.CommandResponse[];
onFocus?: React.FocusEventHandler;
onPaste?: React.ClipboardEventHandler;
additionalTextareaProps: object;
}

export interface ChatDownProps extends TranslationContextValue {
Expand Down

0 comments on commit 45944ce

Please sign in to comment.