Skip to content

Commit

Permalink
fix(#150): add maxlength on input (#222)
Browse files Browse the repository at this point in the history
* fix(issue#150): add maxlength on input

* fix: lint problems
  • Loading branch information
jufab authored Apr 23, 2024
1 parent d7932b3 commit b8dff94
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion webapp/src/components/user_selector/autocomplete_selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import React, {CSSProperties} from 'react';

import {components} from 'react-select';
import AsyncSelect from 'react-select/async';
import {OptionsType, ValueType, Theme as ComponentTheme} from 'react-select/src/types';
import {Props as ComponentProps, StylesConfig} from 'react-select/src/styles';
Expand Down Expand Up @@ -51,7 +52,7 @@ const useTheme = (mattermostTheme: Theme): [StylesConfig, ThemeConfig] => {
return [styles, compTheme];
};

const renderOption = (option: UserProfile, {context} : {context: FormatOptionLabelContext}) => {
const renderOption = (option: UserProfile, {context}: {context: FormatOptionLabelContext}) => {
const {username} = option;
const name = `@${username}`;
const description = getDescription(option);
Expand Down Expand Up @@ -116,6 +117,13 @@ export default function AutocompleteSelector(props: Props) {
);
}

//@ts-ignore
const Input = (inputProps) => (
<components.Input
{...inputProps}
maxLength={22}
/>);

return (
<div
data-testid='autoCompleteSelector'
Expand All @@ -124,6 +132,7 @@ export default function AutocompleteSelector(props: Props) {
{labelContent}
<div className={inputClassName}>
<AsyncSelect
components={{Input}}
autoFocus={Boolean(props.autoFocus)}
cacheOptions={true}
loadOptions={loadOptions}
Expand Down

0 comments on commit b8dff94

Please sign in to comment.