fix: disable link navigation and align breadcrumb actions and date focus
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
cloneVNode,
|
||||
defineComponent,
|
||||
h,
|
||||
inject,
|
||||
isVNode,
|
||||
useAttrs,
|
||||
type PropType,
|
||||
@@ -14,6 +15,7 @@ import {
|
||||
import { breadcrumbsVariants } from "@heroui-vue/styles";
|
||||
import { useInheritedDisabled } from "../field/disabled";
|
||||
import Link from "../link/Link.vue";
|
||||
import { breadcrumbsActionKey } from "./context";
|
||||
import BreadcrumbsSeparatorIcon from "./BreadcrumbsSeparatorIcon.vue";
|
||||
|
||||
function flattenChildren(
|
||||
@@ -57,6 +59,10 @@ export default defineComponent({
|
||||
name: "BreadcrumbsItem",
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
id: {
|
||||
type: [String, Number] as PropType<string | number>,
|
||||
default: undefined,
|
||||
},
|
||||
href: {
|
||||
type: String,
|
||||
default: undefined,
|
||||
@@ -77,6 +83,11 @@ export default defineComponent({
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
/** Identity supplied by the parent from id/key/index. */
|
||||
itemKey: {
|
||||
type: [String, Number] as PropType<string | number>,
|
||||
default: undefined,
|
||||
},
|
||||
/** Set by Breadcrumbs for the final item. */
|
||||
isLast: {
|
||||
type: Boolean,
|
||||
@@ -94,6 +105,7 @@ export default defineComponent({
|
||||
},
|
||||
},
|
||||
setup(props, { attrs, slots }) {
|
||||
const action = inject(breadcrumbsActionKey, undefined);
|
||||
const variants = breadcrumbsVariants();
|
||||
const disabled = useInheritedDisabled(
|
||||
() => props.isDisabled || props.isLast,
|
||||
@@ -136,6 +148,19 @@ export default defineComponent({
|
||||
else rootAttrs[key] = value;
|
||||
}
|
||||
|
||||
const onClick = linkAttrs.onClick;
|
||||
linkAttrs.onClick = [
|
||||
...(Array.isArray(onClick) ? onClick : onClick ? [onClick] : []),
|
||||
(event: MouseEvent) => {
|
||||
if (
|
||||
!event.defaultPrevented &&
|
||||
!disabled.value &&
|
||||
props.itemKey !== undefined
|
||||
)
|
||||
action?.(props.itemKey);
|
||||
},
|
||||
];
|
||||
|
||||
const content =
|
||||
slots.default?.({
|
||||
isCurrent: current,
|
||||
@@ -172,6 +197,7 @@ export default defineComponent({
|
||||
props.as,
|
||||
{
|
||||
...rootAttrs,
|
||||
id: props.id == null ? undefined : String(props.id),
|
||||
class: [variants.item(), callerClass],
|
||||
"data-slot": "breadcrumbs-item",
|
||||
"data-current": current ? "true" : undefined,
|
||||
|
||||
Reference in New Issue
Block a user