From 68387c216d6a7bbcd9850c79390e774f6a53a7f3 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Thu, 31 May 2018 15:07:25 +0200 Subject: [PATCH] Remove ARIA roles and arrows navigation. --- editor/components/inserter/item-list.js | 55 +------------------------ 1 file changed, 2 insertions(+), 53 deletions(-) diff --git a/editor/components/inserter/item-list.js b/editor/components/inserter/item-list.js index cc6fb8b63bd42a..703cac6221fa7a 100644 --- a/editor/components/inserter/item-list.js +++ b/editor/components/inserter/item-list.js @@ -1,14 +1,12 @@ /** * External dependencies */ -import { isEqual } from 'lodash'; import classnames from 'classnames'; /** * WordPress dependencies */ import { Component } from '@wordpress/element'; -import { NavigableMenu } from '@wordpress/components'; import { getBlockMenuDefaultClassName } from '@wordpress/blocks'; /** @@ -16,63 +14,15 @@ import { getBlockMenuDefaultClassName } from '@wordpress/blocks'; */ import BlockIcon from '../block-icon'; -function deriveActiveItems( items ) { - return items.filter( ( item ) => ! item.isDisabled ); -} - class ItemList extends Component { - constructor() { - super( ...arguments ); - this.onNavigate = this.onNavigate.bind( this ); - this.activeItems = deriveActiveItems( this.props.items ); - this.state = { - current: this.activeItems.length > 0 ? this.activeItems[ 0 ] : null, - }; - } - - componentDidUpdate( prevProps ) { - if ( ! isEqual( this.props.items, prevProps.items ) ) { - this.activeItems = deriveActiveItems( this.props.items ); - - // Try and preserve any still valid selected state. - const currentIsStillActive = this.state.current && this.activeItems.some( ( item ) => - item.id === this.state.current.id - ); - - if ( ! currentIsStillActive ) { - this.setState( { - current: this.activeItems.length > 0 ? this.activeItems[ 0 ] : null, - } ); - } - } - } - - onNavigate( index ) { - const { activeItems } = this; - const dest = activeItems[ index ]; - if ( dest ) { - this.setState( { - current: dest, - } ); - } - } - render() { const { items, onSelect, onHover } = this.props; - const { current } = this.state; return ( - +
{ items.map( ( item ) => { - const isCurrent = current && current.id === item.id; return ( ); } ) } - +
); } }