mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* fixes space name being read twice on the space selector screen * fix comment * fix type checks
This commit is contained in:
parent
7eee7cc427
commit
ea92634080
7 changed files with 63 additions and 6 deletions
|
@ -1,5 +1,42 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`removes aria-label when instructed not to announce the space name 1`] = `
|
||||
<Component
|
||||
announceSpaceName={false}
|
||||
space={
|
||||
Object {
|
||||
"id": "",
|
||||
"name": "",
|
||||
}
|
||||
}
|
||||
>
|
||||
<EuiAvatar
|
||||
aria-label=""
|
||||
color="#BFA180"
|
||||
data-test-subj="space-avatar-"
|
||||
initials=""
|
||||
initialsLength={2}
|
||||
name=""
|
||||
size="m"
|
||||
type="space"
|
||||
>
|
||||
<div
|
||||
aria-label=""
|
||||
className="euiAvatar euiAvatar--m euiAvatar--space"
|
||||
data-test-subj="space-avatar-"
|
||||
style={
|
||||
Object {
|
||||
"backgroundColor": "#BFA180",
|
||||
"backgroundImage": "none",
|
||||
"color": "#000000",
|
||||
}
|
||||
}
|
||||
title=""
|
||||
/>
|
||||
</EuiAvatar>
|
||||
</Component>
|
||||
`;
|
||||
|
||||
exports[`renders with a space name entirely made of whitespace 1`] = `
|
||||
<EuiAvatar
|
||||
color="#DB1374"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { shallow } from 'enzyme';
|
||||
import { mount, shallow } from 'enzyme';
|
||||
import React from 'react';
|
||||
import { SpaceAvatar } from './space_avatar';
|
||||
|
||||
|
@ -17,3 +17,8 @@ test('renders with a space name entirely made of whitespace', () => {
|
|||
const wrapper = shallow(<SpaceAvatar space={{ name: ' ', id: '' }} />);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('removes aria-label when instructed not to announce the space name', () => {
|
||||
const wrapper = mount(<SpaceAvatar space={{ name: '', id: '' }} announceSpaceName={false} />);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { EuiAvatar } from '@elastic/eui';
|
||||
import React from 'react';
|
||||
import React, { SFC } from 'react';
|
||||
import { getSpaceColor, getSpaceInitials, MAX_SPACE_INITIALS } from '../../common';
|
||||
import { Space } from '../../common/model/space';
|
||||
|
||||
|
@ -13,10 +13,11 @@ interface Props {
|
|||
space: Partial<Space>;
|
||||
size?: 's' | 'm' | 'l' | 'xl';
|
||||
className?: string;
|
||||
announceSpaceName?: boolean;
|
||||
}
|
||||
|
||||
export const SpaceAvatar = (props: Props) => {
|
||||
const { space, size, ...rest } = props;
|
||||
export const SpaceAvatar: SFC<Props> = (props: Props) => {
|
||||
const { space, size, announceSpaceName, ...rest } = props;
|
||||
|
||||
const spaceName = space.name ? space.name.trim() : '';
|
||||
|
||||
|
@ -25,6 +26,10 @@ export const SpaceAvatar = (props: Props) => {
|
|||
type="space"
|
||||
data-test-subj={`space-avatar-${space.id}`}
|
||||
name={spaceName}
|
||||
{...!announceSpaceName && {
|
||||
// provide empty aria-label so EUI doesn't try to provide its own
|
||||
'aria-label': '',
|
||||
}}
|
||||
size={size || 'm'}
|
||||
initialsLength={MAX_SPACE_INITIALS}
|
||||
initials={getSpaceInitials(space)}
|
||||
|
@ -33,3 +38,7 @@ export const SpaceAvatar = (props: Props) => {
|
|||
/>
|
||||
);
|
||||
};
|
||||
|
||||
SpaceAvatar.defaultProps = {
|
||||
announceSpaceName: true,
|
||||
};
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
// @ts-nocheck
|
||||
|
||||
import {
|
||||
// FIXME: need updated typedefs
|
||||
|
@ -34,7 +33,9 @@ export const SpaceCard = (props: Props) => {
|
|||
};
|
||||
|
||||
function renderSpaceAvatar(space: Space) {
|
||||
return <SpaceAvatar space={space} size={'l'} />;
|
||||
// not announcing space name here because the title of the EuiCard that the SpaceAvatar lives in is already
|
||||
// announcing it. See https://github.com/elastic/kibana/issues/27748
|
||||
return <SpaceAvatar space={space} size={'l'} announceSpaceName={false} />;
|
||||
}
|
||||
|
||||
function renderSpaceDescription(space: Space) {
|
||||
|
|
|
@ -15,6 +15,7 @@ exports[`AdvancedSettingsTitle renders as expected 1`] = `
|
|||
grow={false}
|
||||
>
|
||||
<Component
|
||||
announceSpaceName={true}
|
||||
space={
|
||||
Object {
|
||||
"id": "my-space",
|
||||
|
|
|
@ -141,6 +141,7 @@ exports[`SpacesGridPage renders as expected 1`] = `
|
|||
exports[`SpacesGridPage renders the list of spaces 1`] = `
|
||||
Array [
|
||||
<Component
|
||||
announceSpaceName={true}
|
||||
size="s"
|
||||
space={
|
||||
Object {
|
||||
|
@ -181,6 +182,7 @@ Array [
|
|||
</EuiAvatar>
|
||||
</Component>,
|
||||
<Component
|
||||
announceSpaceName={true}
|
||||
size="s"
|
||||
space={
|
||||
Object {
|
||||
|
@ -220,6 +222,7 @@ Array [
|
|||
</EuiAvatar>
|
||||
</Component>,
|
||||
<Component
|
||||
announceSpaceName={true}
|
||||
size="s"
|
||||
space={
|
||||
Object {
|
||||
|
|
|
@ -7,6 +7,7 @@ exports[`NavControlPopover renders without crashing 1`] = `
|
|||
<SpacesGlobalNavButton
|
||||
linkIcon={
|
||||
<Unknown
|
||||
announceSpaceName={true}
|
||||
className="spaceNavGraphic"
|
||||
size="s"
|
||||
space={
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue