Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EuiNavDrawer focus management, flyout auto-close #2749

Merged
merged 14 commits into from
Jan 10, 2020
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
- Converted `EuiRangeInput` to TypeScript ([#2732](https://github.com/elastic/eui/pull/2732))
- Added `bellSlash` glyph to `EuiIcon` ([#2714](https://github.com/elastic/eui/pull/2714))
- Added `legend` prop to `EuiCheckboxGroup` and `EuiRadioGroup` to add `EuiFieldset` wrappers for title the groups ([#2739](https://github.com/elastic/eui/pull/2739))
- Changed `EuiNavDrawerFlyout` to close after child nav items are clicked ([#2749](https://github.com/elastic/eui/pull/2749))
- Changed `EuiNavDrawerFlyout` to trap focus while navigating via keyboard ([#2749](https://github.com/elastic/eui/pull/2749))

**Bug fixes**

Expand Down
320 changes: 224 additions & 96 deletions src-docs/src/views/nav_drawer/nav_drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,110 +121,223 @@ export default class extends Component {
},
];

this.exploreLinks = [
this.adminLinks = [
{
label: 'Canvas',
href: '#/layout/nav-drawer',
iconType: 'canvasApp',
isActive: true,
extraAction: {
...pinExtraActionFn('Canvas'),
alwaysShow: true,
label: 'Admin',
iconType: 'managementApp',
flyoutMenu: {
title: 'Tools and settings',
listItems: [
{
label: 'Dev tools',
href: '#/layout/nav-drawer',
iconType: 'devToolsApp',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
iconSize: 's',
'aria-label': 'Add to favorites',
},
},
{
label: 'Stack Monitoring',
href: '#/layout/nav-drawer',
iconType: 'monitoringApp',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
iconSize: 's',
'aria-label': 'Add to favorites',
},
},
{
label: 'Stack Management',
href: '#/layout/nav-drawer',
iconType: 'managementApp',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
iconSize: 's',
'aria-label': 'Add to favorites',
},
},
{
label: 'Nature Plugin (image as icon)',
href: '#/layout/nav-drawer',
extraAction: { ...pinExtraActionFn('Nature Plugin') },
icon: (
<EuiImage
size="s"
alt="Random nature image"
url="https://source.unsplash.com/300x300/?Nature"
/>
),
},
],
},
},
{
label: 'Discover',
href: '#/layout/nav-drawer',
iconType: 'discoverApp',
extraAction: { ...pinExtraActionFn('Discover') },
},
{
label: 'Visualize',
href: '#/layout/nav-drawer',
iconType: 'visualizeApp',
extraAction: { ...pinExtraActionFn('Visualize') },
},
{
label: 'Dashboard',
href: '#/layout/nav-drawer',
iconType: 'dashboardApp',
extraAction: { ...pinExtraActionFn('Dashboard') },
},
{
label: 'Machine learning',
href: '#/layout/nav-drawer',
iconType: 'machineLearningApp',
extraAction: { ...pinExtraActionFn('Machine learning') },
},
{
label: 'Custom Plugin (no icon)',
href: '#/layout/nav-drawer',
extraAction: { ...pinExtraActionFn('Custom Plugin') },
},
{
label: 'Nature Plugin (image as icon)',
href: '#/layout/nav-drawer',
extraAction: { ...pinExtraActionFn('Nature Plugin') },
icon: (
<EuiImage
size="s"
alt="Random nature image"
url="https://source.unsplash.com/300x300/?Nature"
/>
),
},
];

this.solutionsLinks = [
{
label: 'APM',
href: '#/layout/nav-drawer',
iconType: 'apmApp',
extraAction: { ...pinExtraActionFn('APM') },
},
{
label: 'Metrics',
href: '#/layout/nav-drawer',
iconType: 'metricsApp',
extraAction: { ...pinExtraActionFn('Infrastructure') },
},
{
label: 'Logs',
href: '#/layout/nav-drawer',
iconType: 'logsApp',
extraAction: { ...pinExtraActionFn('Log viewer') },
},
this.analyzeLinks = [
{
label: 'Uptime',
href: '#/layout/nav-drawer',
iconType: 'upgradeAssistantApp',
extraAction: { ...pinExtraActionFn('Uptime') },
label: 'Analyze',
iconType: 'logoBusinessAnalytics',
flyoutMenu: {
title: 'Analyze your data',
listItems: [
{
label: 'Discover',
href: '#/layout/nav-drawer',
iconType: 'discoverApp',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
iconSize: 's',
'aria-label': 'Add to favorites',
},
},
{
label: 'Visualize',
href: '#/layout/nav-drawer',
iconType: 'visualizeApp',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
iconSize: 's',
'aria-label': 'Add to favorites',
},
},
{
label: 'Canvas',
href: '#/layout/nav-drawer',
iconType: 'canvasApp',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
iconSize: 's',
'aria-label': 'Add to favorites',
},
},
{
label: 'Maps',
href: '#/layout/nav-drawer',
iconType: 'gisApp',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
iconSize: 's',
'aria-label': 'Add to favorites',
},
},
{
label: 'Machine Learning',
href: '#/layout/nav-drawer',
iconType: 'machineLearningApp',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
iconSize: 's',
'aria-label': 'Add to favorites',
},
},
{
label: 'Graph',
href: '#/layout/nav-drawer',
iconType: 'graphApp',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
iconSize: 's',
'aria-label': 'Add to favorites',
},
},
],
},
},
];
this.securityLinks = [
{
label: 'Maps',
href: '#/layout/nav-drawer',
iconType: 'gisApp',
extraAction: { ...pinExtraActionFn('Maps') },
label: 'Security',
iconType: 'logoSecurity',
flyoutMenu: {
title: 'Security',
listItems: [
{
label: 'SIEM',
href: '#/layout/nav-drawer',
iconType: 'securityApp',
extraAction: { ...pinExtraActionFn('SIEM') },
},
{
label: 'Endpoints',
href: '#/layout/nav-drawer',
iconType: 'securityAnalyticsApp',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
iconSize: 's',
'aria-label': 'Add to favorites',
},
},
],
},
},
];
this.searchLinks = [
{
label: 'SIEM',
href: '#/layout/nav-drawer',
iconType: 'securityAnalyticsApp',
extraAction: { ...pinExtraActionFn('SIEM') },
label: 'Enterprise Search',
iconType: 'logoAppSearch',
flyoutMenu: {
title: 'Enterprise search',
listItems: [
{
label: 'Site search',
href: '#/layout/nav-drawer',
iconType: 'searchProfilerApp',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
iconSize: 's',
'aria-label': 'Add to favorites',
},
},
{
label: 'App search',
href: '#/layout/nav-drawer',
iconType: 'searchProfilerApp',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
iconSize: 's',
'aria-label': 'Add to favorites',
},
},
{
label: 'Workplace search',
href: '#/layout/nav-drawer',
iconType: 'searchProfilerApp',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
iconSize: 's',
'aria-label': 'Add to favorites',
},
},
],
},
},
];

this.adminLinks = [
this.observabilityLinks = [
{
label: 'Admin',
iconType: 'managementApp',
label: 'Observability',
iconType: 'logoMetrics',
flyoutMenu: {
title: 'Tools and settings',
title: 'Observe your operations',
listItems: [
{
label: 'Dev tools',
label: 'Logs',
href: '#/layout/nav-drawer',
iconType: 'devToolsApp',
iconType: 'logsApp',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
Expand All @@ -233,9 +346,9 @@ export default class extends Component {
},
},
{
label: 'Stack Monitoring',
label: 'Metrics',
href: '#/layout/nav-drawer',
iconType: 'monitoringApp',
iconType: 'metricsApp',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
Expand All @@ -244,9 +357,20 @@ export default class extends Component {
},
},
{
label: 'Stack Management',
label: 'APM',
href: '#/layout/nav-drawer',
iconType: 'managementApp',
iconType: 'apmApp',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
iconSize: 's',
'aria-label': 'Add to favorites',
},
},
{
label: 'Uptime',
href: '#/layout/nav-drawer',
iconType: 'uptimeApp',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
Expand All @@ -262,9 +386,9 @@ export default class extends Component {

onKeyDown = event => {
if (event.keyCode === keyCodes.ESCAPE) {
event.preventDefault();
event.stopPropagation();
this.closeFullScreen();
// event.preventDefault();
// event.stopPropagation();
// this.closeFullScreen();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will revert this or make this not collide with new ESC behavior

}
};

Expand Down Expand Up @@ -387,9 +511,13 @@ export default class extends Component {
<EuiNavDrawer ref={this.setNavDrawerRef}>
<EuiNavDrawerGroup listItems={this.topLinks} />
<EuiHorizontalRule margin="none" />
<EuiNavDrawerGroup listItems={this.exploreLinks} />
<EuiNavDrawerGroup listItems={this.analyzeLinks} />
<EuiHorizontalRule margin="none" />
<EuiNavDrawerGroup listItems={this.securityLinks} />
<EuiHorizontalRule margin="none" />
<EuiNavDrawerGroup listItems={this.searchLinks} />
<EuiHorizontalRule margin="none" />
<EuiNavDrawerGroup listItems={this.solutionsLinks} />
<EuiNavDrawerGroup listItems={this.observabilityLinks} />
<EuiHorizontalRule margin="none" />
<EuiNavDrawerGroup listItems={this.adminLinks} />
</EuiNavDrawer>
Expand Down
Loading