mirror of
https://github.com/element-hq/element-web
synced 2024-11-23 17:56:01 +03:00
Cleanup autocomplete
This commit is contained in:
parent
e173900808
commit
884abbd7e9
8 changed files with 28 additions and 24 deletions
|
@ -54,10 +54,7 @@ export default class AutocompleteProvider {
|
|||
}
|
||||
|
||||
renderCompletions(completions: [React.Component]): ?React.Component {
|
||||
return (
|
||||
<div>
|
||||
{completions}
|
||||
</div>
|
||||
);
|
||||
console.error('stub; should be implemented in subclasses');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,8 +85,8 @@ export default class CommandProvider extends AutocompleteProvider {
|
|||
}
|
||||
|
||||
renderCompletions(completions: [React.Component]): ?React.Component {
|
||||
return React.cloneElement(super.renderCompletions(completions), {
|
||||
className: 'mx_Autocomplete_Completion_container_block',
|
||||
});
|
||||
return <div className="mx_Autocomplete_Completion_container_block">
|
||||
{completions}
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ export class TextualCompletion extends React.Component {
|
|||
} = this.props;
|
||||
return (
|
||||
<div className={classNames('mx_Autocomplete_Completion_block', className)} {...restProps}>
|
||||
<span>{title}</span>
|
||||
<em style={{flex: 1}}>{subtitle}</em>
|
||||
<span style={{color: 'gray', float: 'right'}}>{description}</span>
|
||||
<span className="mx_Autocomplete_Completion_title">{title}</span>
|
||||
<span className="mx_Autocomplete_Completion_subtitle">{subtitle}</span>
|
||||
<span className="mx_Autocomplete_Completion_description">{description}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -46,9 +46,9 @@ export class PillCompletion extends React.Component {
|
|||
return (
|
||||
<div className={classNames('mx_Autocomplete_Completion_pill', className)} {...restProps}>
|
||||
{initialComponent}
|
||||
<span>{title}</span>
|
||||
<em>{subtitle}</em>
|
||||
<span style={{color: 'gray'}}>{description}</span>
|
||||
<span className="mx_Autocomplete_Completion_title">{title}</span>
|
||||
<span className="mx_Autocomplete_Completion_subtitle">{subtitle}</span>
|
||||
<span className="mx_Autocomplete_Completion_description">{description}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -87,4 +87,10 @@ export default class DuckDuckGoProvider extends AutocompleteProvider {
|
|||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
renderCompletions(completions: [React.Component]): ?React.Component {
|
||||
return <div className="mx_Autocomplete_Completion_container_block">
|
||||
{completions}
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,8 +49,8 @@ export default class EmojiProvider extends AutocompleteProvider {
|
|||
}
|
||||
|
||||
renderCompletions(completions: [React.Component]): ?React.Component {
|
||||
return React.cloneElement(super.renderCompletions(completions), {
|
||||
className: 'mx_Autocomplete_Completion_container_pill',
|
||||
});
|
||||
return <div className="mx_Autocomplete_Completion_container_pill">
|
||||
{completions}
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,8 +64,8 @@ export default class RoomProvider extends AutocompleteProvider {
|
|||
}
|
||||
|
||||
renderCompletions(completions: [React.Component]): ?React.Component {
|
||||
return React.cloneElement(super.renderCompletions(completions), {
|
||||
className: 'mx_Autocomplete_Completion_container_pill',
|
||||
});
|
||||
return <div className="mx_Autocomplete_Completion_container_pill">
|
||||
{completions}
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,8 +60,8 @@ export default class UserProvider extends AutocompleteProvider {
|
|||
}
|
||||
|
||||
renderCompletions(completions: [React.Component]): ?React.Component {
|
||||
return React.cloneElement(super.renderCompletions(completions), {
|
||||
className: 'mx_Autocomplete_Completion_container_pill',
|
||||
});
|
||||
return <div className="mx_Autocomplete_Completion_container_pill">
|
||||
{completions}
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,7 +105,8 @@ export default class Autocomplete extends React.Component {
|
|||
// this is the selected completion, so scroll it into view if needed
|
||||
const selectedCompletion = this.refs[`completion${this.state.selectionOffset}`];
|
||||
if (selectedCompletion && this.container) {
|
||||
const {offsetTop} = ReactDOM.findDOMNode(selectedCompletion);
|
||||
const domNode = ReactDOM.findDOMNode(selectedCompletion);
|
||||
const offsetTop = domNode && domNode.offsetTop;
|
||||
if (offsetTop > this.container.scrollTop + this.container.offsetHeight ||
|
||||
offsetTop < this.container.scrollTop) {
|
||||
this.container.scrollTop = offsetTop - this.container.offsetTop;
|
||||
|
|
Loading…
Reference in a new issue