Skip to content
Extraits de code Groupes Projets
Valider 66fda37f rédigé par Jeong Arm's avatar Jeong Arm Validation de Eugen Rochko
Parcourir les fichiers

Scroll into search bar when focus (#12032)

parent b85fb6b5
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -60,12 +60,17 @@ class Search extends React.PureComponent {
onShow: PropTypes.func.isRequired,
openInRoute: PropTypes.bool,
intl: PropTypes.object.isRequired,
singleColumn: PropTypes.bool,
};
state = {
expanded: false,
};
setRef = c => {
this.searchForm = c;
}
handleChange = (e) => {
this.props.onChange(e.target.value);
}
......@@ -95,6 +100,13 @@ class Search extends React.PureComponent {
handleFocus = () => {
this.setState({ expanded: true });
this.props.onShow();
if (this.searchForm && !this.props.singleColumn) {
const { left, right } = this.searchForm.getBoundingClientRect();
if (left < 0 || right > (window.innerWidth || document.documentElement.clientWidth)) {
this.searchForm.scrollIntoView();
}
}
}
handleBlur = () => {
......@@ -111,6 +123,7 @@ class Search extends React.PureComponent {
<label>
<span style={{ display: 'none' }}>{intl.formatMessage(messages.placeholder)}</span>
<input
ref={this.setRef}
className='search__input'
type='text'
placeholder={intl.formatMessage(messages.placeholder)}
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter