Restore expand animation on autocomplete suggestions
parent
80bbb584db
commit
185dd37202
|
@ -10,6 +10,8 @@ import InjectChip from '../chip/Chip.js';
|
||||||
import InjectInput from '../input/Input.js';
|
import InjectInput from '../input/Input.js';
|
||||||
import events from '../utils/events.js';
|
import events from '../utils/events.js';
|
||||||
import Portal from '../hoc/Portal';
|
import Portal from '../hoc/Portal';
|
||||||
|
import TransitionGroup from 'react-transition-group/TransitionGroup';
|
||||||
|
import Transition from 'react-transition-group/Transition';
|
||||||
|
|
||||||
const POSITION = {
|
const POSITION = {
|
||||||
AUTO: 'auto',
|
AUTO: 'auto',
|
||||||
|
@ -190,6 +192,7 @@ const factory = (Chip, Input) => {
|
||||||
if (maxHeight > screen_height*0.45) {
|
if (maxHeight > screen_height*0.45) {
|
||||||
maxHeight = Math.floor(screen_height*0.45);
|
maxHeight = Math.floor(screen_height*0.45);
|
||||||
}
|
}
|
||||||
|
maxHeight = maxHeight+'px';
|
||||||
if (this.state.top !== top || this.state.left !== left ||
|
if (this.state.top !== top || this.state.left !== left ||
|
||||||
this.state.width !== width || this.state.bottom !== bottom ||
|
this.state.width !== width || this.state.bottom !== bottom ||
|
||||||
this.state.maxHeight !== maxHeight) {
|
this.state.maxHeight !== maxHeight) {
|
||||||
|
@ -378,7 +381,7 @@ const factory = (Chip, Input) => {
|
||||||
|
|
||||||
renderSuggestions() {
|
renderSuggestions() {
|
||||||
const { theme } = this.props;
|
const { theme } = this.props;
|
||||||
const suggestions = [...this.suggestions()].map(([key, value]) => {
|
return [...this.suggestions()].map(([key, value]) => {
|
||||||
const className = classnames(theme.suggestion, { [theme.active]: this.state.active === key });
|
const className = classnames(theme.suggestion, { [theme.active]: this.state.active === key });
|
||||||
return (
|
return (
|
||||||
<li
|
<li
|
||||||
|
@ -392,14 +395,22 @@ const factory = (Chip, Input) => {
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
renderSuggestionList() {
|
||||||
|
const { theme } = this.props;
|
||||||
const { top, bottom, maxHeight, left, width } = this.state;
|
const { top, bottom, maxHeight, left, width } = this.state;
|
||||||
return (<div style={{position: 'absolute', top, left, width}}>
|
return (<TransitionGroup style={{position: 'absolute', top, left, width}}>
|
||||||
<ul style={{bottom, maxHeight}}
|
<Transition
|
||||||
className={theme.suggestions}>
|
appear={true}
|
||||||
{suggestions}
|
timeout={0}
|
||||||
</ul>
|
onEntered={(node, appearing) => { node.style.maxHeight = maxHeight; }}>
|
||||||
</div>);
|
<ul style={{bottom}}
|
||||||
|
className={theme.suggestions}>
|
||||||
|
{this.renderSuggestions()}
|
||||||
|
</ul>
|
||||||
|
</Transition>
|
||||||
|
</TransitionGroup>);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -436,7 +447,7 @@ const factory = (Chip, Input) => {
|
||||||
value={this.state.query}
|
value={this.state.query}
|
||||||
/>
|
/>
|
||||||
<Portal>
|
<Portal>
|
||||||
{this.state.focus ? this.renderSuggestions() : null}
|
{this.state.focus ? this.renderSuggestionList() : null}
|
||||||
</Portal>
|
</Portal>
|
||||||
{this.props.selectedPosition === 'below' ? this.renderSelected() : null}
|
{this.props.selectedPosition === 'below' ? this.renderSelected() : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background-color: var(--autocomplete-suggestions-background);
|
background-color: var(--autocomplete-suggestions-background);
|
||||||
list-style: none;
|
list-style: none;
|
||||||
max-height: 0;
|
max-height: 1px;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
@ -50,7 +50,6 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
z-index: var(--z-index-highest);
|
z-index: var(--z-index-highest);
|
||||||
box-shadow: var(--zdepth-shadow-1);
|
box-shadow: var(--zdepth-shadow-1);
|
||||||
max-height: var(--autocomplete-overflow-max-height);
|
|
||||||
-ms-overflow-style: none;
|
-ms-overflow-style: none;
|
||||||
|
|
||||||
&::-webkit-scrollbar {
|
&::-webkit-scrollbar {
|
||||||
|
|
Loading…
Reference in New Issue