score:3
Accepted answer
I came across the same issue. With react-mention you don't have to use the react-text-autosize as you can achieve the same behavior with css which can auto grow the textarea generated. Consider following example
<MentionsInput
value={content}
placeholder="Add a comment"
onChange={this.onChange}
className="mentionWrapper">
<Mention
trigger="@"
data={users}
className="mentionedFriend"
displayTransform={(id, display) => `@${display}`}
/>
</MentionsInput>
For this i've used the following styles
.mentionWrapper {
width: 100%;
background: transparent;
font-size: 0.9rem;
color: #a9b5c4;
}
.mentionWrapper .mentionWrapper__control {
border-radius: 25px;
border: 1px solid #3a546f;
min-height: 45px;
}
.mentionWrapper .mentionWrapper__control .mentionWrapper__highlighter {
padding: 0.7rem 1rem;
}
.mentionWrapper .mentionWrapper__control .mentionWrapper__input {
padding: 0.7rem 1rem;
outline: 0;
border: 0;
resize: none;
outline: none;
font-size: 0.9rem;
color: #7288a3;
border-color: #3a546f;
overflow: hidden;
}
.mentionWrapper .mentionWrapper__control .mentionWrapper__input::placeholder {
color: #7288a3;
}
.mentionWrapper__suggestions {
background-color: rgba(0, 0, 0, 0.6) !important;
padding: 10px;
-webkit-box-shadow: 0px 0px 11px 0px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 0px 0px 11px 0px rgba(0, 0, 0, 0.75);
box-shadow: 0px 0px 11px 0px rgba(0, 0, 0, 0.75);
border-radius: 0.8rem;
}
.mentionWrapper__suggestions .mentionWrapper__suggestions__list {
font-size: 14px;
}
.mentionWrapper
.mentionWrapper__suggestions
.mentionWrapper__suggestions__item--focused {
color: #ffffff;
border-bottom: 1px solid #3a546f;
font-weight: 600;
}
.mentionedFriend {
color: #7288a3;
text-decoration: underline;
}
Key point here is that i've applied a min-height of 45px to "control" div which is append by react-mention package. By doing so you will get the attached result.
Source: stackoverflow.com
Related Query
- How to make react semantic UI TextArea with default value, but still allows user to change the value?
- how to store textarea new line value into array with react and send it to node js variable with post request
- How to call loading function with React useEffect only once
- How to use refs in React with Typescript
- How to use callback with useState hook in react
- How to test a className with the Jest and React testing library
- How to use children with React Stateless Functional Component in TypeScript?
- How to use throttle or debounce with React Hook?
- How to specify (optional) default props with TypeScript for stateless, functional React components?
- How to apply global styles with CSS modules in a react app?
- How to import CSS modules with Typescript, React and Webpack
- How to mock React component methods with jest and enzyme
- How to test style for a React component attribute with Enzyme
- How to implement Error Boundary with React Hooks Component
- How to use React Router with Electron?
- How to use Redux's Provider with React
- How target DOM with react useRef in map
- How to fetch the new data in response to React Router change with Redux?
- How to CSS display:none within conditional with React JSX?
- How to create a React Modal (which is appended to <body>) with transitions?
- How to avoid React loading twice with Webpack when developing
- How to set up Babel 6 stage 0 with React and Webpack
- React JSX, how to render text with a single quote? Example <p>I've</p>
- How to use jQuery UI with React JS
- How to use shouldComponentUpdate with React Hooks?
- How to focus something on next render with React Hooks
- How to mock history.push with the new React Router Hooks using Jest
- How to override the width of a TextField component with react MUI?
- How to use React useRef hook with typescript?
- How to use create-react-app with an older React version?
More Query from same tag
- How to validate two password fields with Joi in TS React?
- React: 1. Radio button doesn't toggle/selected 2. State gets empty after filtering JSON data
- Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object in ReactJS
- just making the query in parent component and not rendering anything and sending all data as props
- Problem with passing props to child component
- React - Dynamically Render Select Options
- How to give space in between the fields in material UI?
- Error server Error: Actions must be plain objects. Use custom middleware for async actions
- react component not render new data from redux store
- null is not an object (evaluating '_RNGestureHandlerModule.default.Direction')
- How to change the hover colour on Office Fabric UI Nav component
- The input textbox is not letting me insert a value
- Redux-thunk and axios - request cancellation
- How to limit Google Maps Places Autocomplete API results to cities?
- How to create a child component inside a component and render them accordingly?
- The next.js image is transparent
- How to fetch data from API using id in reactJS?
- VS Code not suggesting JSX attributes
- How do I store some values in the broswer scope from a react component?
- How to align an svg next to text in react
- Problem with deploy react app with gh-pages
- React function - is not defined no-undef-- component integration
- Reactjs adding the selected react-bootstrap tab key # to the current URL
- react cannot GET from express.js
- Resolving physical URLs from a webapp that uses react-router
- How to open and close dropdown on btn-click, but in same time with outside click close?
- how I can get the geoJson file for gall-peters world map for react leaflet
- Custom React Hook on Ctrl+S keydown
- How to manage state through Context and typescript
- Styled-component, using theme variables in Render