Skip to content

Commit

Permalink
Fix getPopupContainer ts type
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Mar 21, 2017
1 parent fd7b5bd commit 322e9ef
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion components/cascader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export interface CascaderProps {
onPopupVisibleChange?: (popupVisible: boolean) => void;
prefixCls?: string;
inputPrefixCls?: string;
getPopupContainer?: (triggerNode: Element) => HTMLElement;
getPopupContainer?: (triggerNode?: HTMLElement) => HTMLElement;
}

function highlightKeyword(str: string, keyword: string, prefixCls: string) {
Expand Down
2 changes: 1 addition & 1 deletion components/date-picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface PickerProps {
popupStyle?: React.CSSProperties;
locale?: any;
size?: 'large' | 'small' | 'default';
getCalendarContainer?: (trigger: any) => React.ReactNode;
getCalendarContainer?: (triggerNode?: HTMLElement) => HTMLElement;
open?: boolean;
onOpenChange?: (status: boolean) => void;
disabledDate?: (current: moment.Moment) => boolean;
Expand Down
2 changes: 1 addition & 1 deletion components/dropdown/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface DropDownProps {
onVisibleChange?: (visible?: boolean) => void;
visible?: boolean;
align?: Object;
getPopupContainer?: () => HTMLElement;
getPopupContainer?: (triggerNode?: HTMLElement) => HTMLElement;
prefixCls?: string;
placement?: 'topLeft' | 'topCenter' | 'topRight' | 'bottomLeft' | 'bottomCenter' | 'bottomRight';
}
Expand Down
2 changes: 1 addition & 1 deletion components/mention/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface MentionProps {
multiLines?: Boolean;
prefix?: string;
placeholder?: string;
getSuggestionContainer?: Function;
getSuggestionContainer?: (triggerNode?: HTMLElement) => HTMLElement;
onFocus?: Function;
onBlur?: Function;
}
Expand Down
2 changes: 1 addition & 1 deletion components/select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface SelectProps extends AbstractSelectProps {
optionFilterProp?: string;
defaultActiveFirstOption?: boolean;
labelInValue?: boolean;
getPopupContainer?: (triggerNode: React.ReactNode) => React.ReactNode | HTMLElement;
getPopupContainer?: (triggerNode?: HTMLElement) => HTMLElement;
dropdownStyle?: React.CSSProperties;
dropdownMenuStyle?: React.CSSProperties;
onChange?: (value: SelectValue) => void;
Expand Down
2 changes: 1 addition & 1 deletion components/time-picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface TimePickerProps {
disabledMinutes?: (selectedHour: number) => number[];
disabledSeconds?: (selectedHour: number, selectedMinute: number) => number[];
style?: React.CSSProperties;
getPopupContainer?: (trigger: any) => any;
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
addon?: Function;
}

Expand Down
6 changes: 3 additions & 3 deletions components/tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export interface AbstractTooltipProps {
trigger?: 'hover' | 'focus' | 'click';
openClassName?: string;
arrowPointAtCenter?: boolean;
// getTooltipContainer had been rename to getPopupDomNode
getTooltipContainer?: (triggerNode: Element) => HTMLElement;
getPopupContainer?: (triggerNode: Element) => HTMLElement;
// getTooltipContainer had been rename to getPopupContainer
getTooltipContainer?: (triggerNode?: HTMLElement) => HTMLElement;
getPopupContainer?: (triggerNode?: HTMLElement) => HTMLElement;
children?: React.ReactElement<any>;
}

Expand Down
2 changes: 1 addition & 1 deletion components/tree-select/interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ export interface TreeSelectProps {
notFoundContent?: React.ReactNode;
labelInValue?: boolean;
treeCheckStrictly?: boolean;
getPopupContainer?: (triggerNode: React.ReactNode) => HTMLElement;
getPopupContainer?: (triggerNode?: HTMLElement) => HTMLElement;
}

3 comments on commit 322e9ef

@hjin-me
Copy link

@hjin-me hjin-me commented on 322e9ef Mar 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

322e9ef?diff=split#diff-3141ae7cf791cd0b5edcad2c51dd6dddL63

cascader 似乎是我当初提交的。
我建议 triggerNode 的类型是 Element。

说一下原因。

  1. 阅读源码之后,triggerNode 是通过 findDOMNode 获取元素的,https://github.com/DefinitelyTyped/DefinitelyTyped/blob/354cec620daccfa0ad167ba046651fb5fef69e8a/types/react-dom/index.d.ts 该方法的返回值是 Element 或继承 Element 的类型
  2. SVGElement 和 HTMLElement 都继承自 Element
  3. 测试了一下,可以在 SVGElement 上面正确取得当前组件生效的元素。

@afc163
Copy link
Member Author

@afc163 afc163 commented on 322e9ef Mar 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK,我没有考虑到 SVGElement 的情况。来个 PR 一起修正如何?@hjin-me

@hjin-me
Copy link

@hjin-me hjin-me commented on 322e9ef Mar 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好啊~~~明天白天来提 :)
#5528

Please sign in to comment.