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 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import {getColorStyles, getDescription, getProfilePicture} from '../../utils';

import './autocomplete_selector.scss';
import {components} from 'react-select';

Check failure on line 19 in webapp/src/components/user_selector/autocomplete_selector.tsx

View workflow job for this annotation

GitHub Actions / plugin-ci / lint

`react-select` import should occur before import of `../../utils`
Copy link
Contributor

Choose a reason for hiding this comment

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

This import should be further up with the other react-select imports. This should really be caught by the linter but I think that rule is not set up for this project


type Props = {
loadOptions: (inputValue: string, callback: ((options: OptionsType<UserProfile>) => void)) => Promise<unknown> | void,
Expand All @@ -30,6 +31,7 @@
theme: Theme,
}


Check failure on line 34 in webapp/src/components/user_selector/autocomplete_selector.tsx

View workflow job for this annotation

GitHub Actions / plugin-ci / lint

More than 1 blank line not allowed
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Unnecessary extra line here

const useTheme = (mattermostTheme: Theme): [StylesConfig, ThemeConfig] => {
const mmColors = getColorStyles(mattermostTheme);

Expand Down Expand Up @@ -116,6 +118,9 @@
);
}

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

Check failure on line 122 in webapp/src/components/user_selector/autocomplete_selector.tsx

View workflow job for this annotation

GitHub Actions / plugin-ci / lint

'props' is already declared in the upper scope

Check failure on line 122 in webapp/src/components/user_selector/autocomplete_selector.tsx

View workflow job for this annotation

GitHub Actions / plugin-ci / lint

Prop `maxLength` must be placed on a new line

Check failure on line 122 in webapp/src/components/user_selector/autocomplete_selector.tsx

View workflow job for this annotation

GitHub Actions / plugin-ci / lint

A space is forbidden before closing bracket
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally we don't need to use @ts-ignore. I think we can inline the declaration of this below when defining the components prop, and typescript will automatically infer the type of props

components={{
    Input: (props) => <components.Input {...props} maxLength={22} />,
}}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I inline this code, I have an other problem. 😢

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay then it seems the types for the library don't agree with its supported functionality. Yeah let's just use @ts-ignore here. Thanks for trying this 👍


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