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

fix(#150): add maxlength on input #222

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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