Add tag to SortEvent

In order to check if the event target is a hyperlink and cancel sort if the user clicks a link, the recommended pattern is to check SortEvent.target.tagName. (see https://stackoverflow.com/questions/15661343/check-if-event-target-is-hyperlink). However, the typings do not support this pattern as SortEvent.target does not expect a tag attribute.
This commit is contained in:
Phil Nova
2018-02-26 13:58:54 -08:00
committed by GitHub
parent c6614dd157
commit 77a857abff
+9 -1
View File
@@ -18,6 +18,14 @@ export interface SortStart {
export type SortEvent = React.MouseEvent<any> | React.TouchEvent<any>;
interface Tag extends React.EventTarget {
tagName: string;
}
export interface SortEventWithTag extends SortEvent {
target: Tag;
}
export type SortStartHandler = (sort: SortStart, event: SortEvent) => void;
export type SortMoveHandler = (event: SortEvent) => void;
@@ -45,7 +53,7 @@ export interface SortableContainerProps {
pressDelay?: number;
pressThreshold?: number;
distance?: number;
shouldCancelStart?: (event: SortEvent) => boolean;
shouldCancelStart?: (event: SortEvent | SortEventWithTag) => boolean;
onSortStart?: SortStartHandler;
onSortMove?: SortMoveHandler;
onSortEnd?: SortEndHandler;