Select: fixes so component loses focus on selecting value or pressing outside of input. (#24008)

* changed the value container to a class component to get it to work with focus (maybe something with context?).

* added e2e tests to verify that the select focus is working as it should.

* fixed according to feedback.

* updated snapshot.
This commit is contained in:
Marcus Andersson
2020-04-29 15:02:09 +02:00
committed by GitHub
parent a35babee40
commit be8c62033c
8 changed files with 89 additions and 31 deletions

View File

@@ -1,9 +1,10 @@
import React, { PureComponent } from 'react';
import { debounce } from 'lodash';
import { AsyncSelect } from '@grafana/ui';
import { AppEvents, SelectableValue } from '@grafana/data';
import { debounce } from 'lodash';
import appEvents from '../../app_events';
import { getBackendSrv } from '@grafana/runtime';
import { selectors } from '@grafana/e2e-selectors';
import appEvents from '../../app_events';
import { contextSrv } from 'app/core/services/context_srv';
import { DashboardSearchHit } from 'app/features/search/types';
@@ -148,7 +149,7 @@ export class FolderPicker extends PureComponent<Props, State> {
const { enableCreateNew, useNewForms } = this.props;
return (
<>
<div aria-label={selectors.components.FolderPicker.container}>
{useNewForms && (
<AsyncSelect
loadingMessage="Loading folders..."
@@ -180,7 +181,7 @@ export class FolderPicker extends PureComponent<Props, State> {
</div>
</div>
)}
</>
</div>
);
}
}

View File

@@ -1,7 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`FolderPicker should render 1`] = `
<Fragment>
<div
aria-label="Folder picker select container"
>
<div
className="gf-form-inline"
>
@@ -26,5 +28,5 @@ exports[`FolderPicker should render 1`] = `
/>
</div>
</div>
</Fragment>
</div>
`;