-
Notifications
You must be signed in to change notification settings - Fork 557
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add optional bottom guard for rendering suggestion list (#339)
* adds guard for mentions suggestions list clipped by bottom of window * add guard for suggestionlist without portals * Add prop so that the rendering above is opt in * Add example for bottom guard
- Loading branch information
Showing
4 changed files
with
118 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React from 'react' | ||
import { Mention, MentionsInput } from '../../../src' | ||
|
||
import { provideExampleValue } from './higher-order' | ||
import defaultStyle from './defaultStyle' | ||
import defaultMentionStyle from './defaultMentionStyle' | ||
let container | ||
|
||
function BottomGuard({ value, data, onChange, onAdd }) { | ||
return ( | ||
<div | ||
id="suggestionPortal" | ||
style={{ | ||
height: '400px', | ||
}} | ||
ref={el => { | ||
container = el | ||
}} | ||
> | ||
<h3>Bottom guard example</h3> | ||
<p> | ||
Note that the bottom input will open the suggestions list above the cursor | ||
</p> | ||
<div | ||
style={{ | ||
position: 'absolute', | ||
height: '300px', | ||
width: '400px', | ||
overflow: 'auto', | ||
border: '1px solid green', | ||
padding: '8px', | ||
}} | ||
> | ||
<MentionsInput | ||
value={value} | ||
onChange={onChange} | ||
style={defaultStyle} | ||
placeholder={"Mention people using '@'"} | ||
suggestionsPortalHost={container} | ||
allowSuggestionsAboveCursor={true} | ||
> | ||
<Mention data={data} onAdd={onAdd} style={defaultMentionStyle} /> | ||
</MentionsInput> | ||
<br/> | ||
<br/> | ||
<br/> | ||
<br/> | ||
<br/> | ||
<br/> | ||
<br/> | ||
<br/> | ||
<br/> | ||
<MentionsInput | ||
value={value} | ||
onChange={onChange} | ||
style={defaultStyle} | ||
placeholder={"Mention people using '@'"} | ||
suggestionsPortalHost={container} | ||
allowSuggestionsAboveCursor={true} | ||
> | ||
<Mention data={data} onAdd={onAdd} style={defaultMentionStyle} /> | ||
</MentionsInput> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
const asExample = provideExampleValue('') | ||
|
||
export default asExample(BottomGuard) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38278e0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to following URLs: