feat: Breadcrumb accessibility improvements

pull/5820/head
tangjinzhou 2022-05-10 15:48:14 +08:00
parent 78045b4b5b
commit 3aedf48eaf
3 changed files with 21 additions and 9 deletions

View File

@ -152,7 +152,11 @@ export default defineComponent({
[prefixCls.value]: true,
[`${prefixCls.value}-rtl`]: direction.value === 'rtl',
};
return <div class={breadcrumbClassName}>{crumbs}</div>;
return (
<nav class={breadcrumbClassName}>
<ol>{crumbs}</ol>
</nav>
);
};
},
});

View File

@ -2,7 +2,7 @@ import type { ExtractPropTypes, PropType } from 'vue';
import { defineComponent } from 'vue';
import PropTypes from '../_util/vue-types';
import { getPropsSlot } from '../_util/props-util';
import DropDown from '../dropdown/dropdown';
import Dropdown from '../dropdown/dropdown';
import DownOutlined from '@ant-design/icons-vue/DownOutlined';
import useConfigInject from '../_util/hooks/useConfigInject';
import type { MouseEventHandler } from '../_util/EventInterface';
@ -27,18 +27,18 @@ export default defineComponent({
const { prefixCls } = useConfigInject('breadcrumb', props);
/**
* if overlay is have
* Wrap a DropDown
* Wrap a Dropdown
*/
const renderBreadcrumbNode = (breadcrumbItem: JSX.Element, prefixCls: string) => {
const overlay = getPropsSlot(slots, props, 'overlay');
if (overlay) {
return (
<DropDown overlay={overlay} placement="bottom">
<Dropdown overlay={overlay} placement="bottom">
<span class={`${prefixCls}-overlay-link`}>
{breadcrumbItem}
<DownOutlined />
</span>
</DropDown>
</Dropdown>
);
}
return breadcrumbItem;
@ -66,10 +66,10 @@ export default defineComponent({
link = renderBreadcrumbNode(link, prefixCls.value);
if (children) {
return (
<span class={cls} style={style}>
<li class={cls} style={style}>
{link}
{separator && <span class={`${prefixCls.value}-separator`}>{separator}</span>}
</span>
</li>
);
}
return null;

View File

@ -13,6 +13,14 @@
font-size: @breadcrumb-icon-font-size;
}
ol {
display: flex;
flex-wrap: wrap;
margin: 0;
padding: 0;
list-style: none;
}
a {
color: @breadcrumb-link-color;
transition: color 0.3s;
@ -22,7 +30,7 @@
}
}
& > span:last-child {
li:last-child {
color: @breadcrumb-last-item-color;
a {
@ -30,7 +38,7 @@
}
}
& > span:last-child &-separator {
li:last-child &-separator {
display: none;
}