mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-28 19:55:53 +03:00
omniboxResult: scroll into view if necessary
This commit is contained in:
parent
48ea9d4161
commit
27aa920a7a
@ -10,6 +10,18 @@ export class OmniboxResult extends Component {
|
||||
hovered: false
|
||||
};
|
||||
this.setHover = this.setHover.bind(this);
|
||||
this.result = React.createRef();
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
const { props, state } = this;
|
||||
if (prevProps &&
|
||||
!state.hovered &&
|
||||
prevProps.selected !== props.selected &&
|
||||
props.selected === props.link
|
||||
) {
|
||||
this.result.current.scrollIntoView({ block: 'nearest' });
|
||||
}
|
||||
}
|
||||
|
||||
setHover(boolean) {
|
||||
@ -55,6 +67,7 @@ export class OmniboxResult extends Component {
|
||||
}
|
||||
onClick={navigate}
|
||||
width="100%"
|
||||
ref={this.result}
|
||||
>
|
||||
{this.state.hovered || selected === link ? (
|
||||
<>
|
||||
|
Loading…
Reference in New Issue
Block a user