react-mentions icon indicating copy to clipboard operation
react-mentions copied to clipboard

🙏 Provide renderInput callback for using component library

Open Hideman85 opened this issue 3 years ago • 1 comments

It would be an amazing user experience if we could use our component library to render the input 🙏

import TextField from '@mui/material/TextField';

const renderInput = (props) => <TextField {...props} label='Comment...' />;

export const MentionsTextfield: FC<MentionsTextfieldProps> = ({ options, value, onChange, disabled }) => {
  const inputRef = useRef<HTMLElement>(null);

  useEffect(() => {
    inputRef.current?.focus();
  }, []);

  return (
    <MentionsInput
      ref={inputRef}
      style={defaultStyleMentions}
      singleLine={false}
      disabled={disabled}
      value={value}
      onChange={onChange}
      renderInput={renderInput}
    >
      <Mention appendSpaceOnAdd displayTransform={(_, display) => `@${display} `} trigger='@' markup={MENTION_MARKUP} data={options} />
    </MentionsInput>
  );
};

Hideman85 avatar Sep 30 '22 10:09 Hideman85

There's an open PR by @taifen that solves this, let's bump it up 👍🏻

gioragutt avatar May 25 '24 13:05 gioragutt