Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle some null value branch #2323

Merged
merged 4 commits into from Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
178 changes: 44 additions & 134 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -103,8 +103,8 @@
"@types/react-dom": "^17.0.0",
"@types/sinon": "^10.0.2",
"@types/sinon-chai": "^2.7.38",
"@typescript-eslint/eslint-plugin": "^4.29.2",
"@typescript-eslint/parser": "^4.29.2",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"autoprefixer": "^8.3.0",
"babel-loader": "^8.0.0",
"babel-plugin-istanbul": "^4.1.4",
Expand Down
3 changes: 2 additions & 1 deletion src/Affix/Affix.tsx
Expand Up @@ -22,11 +22,12 @@ function useOffset(mountRef: React.RefObject<HTMLDivElement>) {
const [offset, setOffset] = useState<Offset | null>(null);

const updateOffset = useCallback(() => {
// FIXME upgrade dom-lib
setOffset(getOffset(mountRef.current!));
}, [mountRef]);

// Update after the element size changes
useElementResize(() => mountRef.current!, updateOffset);
useElementResize(() => mountRef.current, updateOffset);

// Initialize after the first render
useMount(updateOffset);
Expand Down
11 changes: 8 additions & 3 deletions src/Calendar/TimeDropdown.tsx
Expand Up @@ -82,8 +82,11 @@ const scrollTo = (time: Time, row: HTMLDivElement) => {
const node = container?.querySelector(`[data-key="${type}-${value}"]`);

if (node && container) {
const { top } = getPosition(node, container)!;
scrollTopAnimation(container, top, scrollTop(container) !== 0);
const position = getPosition(node, container);

if (position) {
scrollTopAnimation(container, position.top, scrollTop(container) !== 0);
}
}
});
};
Expand All @@ -104,7 +107,9 @@ const TimeDropdown: RsRefForwardingComponent<'div', TimeDropdownProps> = React.f
useEffect(() => {
const time = getTime({ format, date, showMeridian });
// The currently selected time scrolls to the visible range.
show && scrollTo(time, rowRef.current!);
if (show && rowRef.current) {
scrollTo(time, rowRef.current);
}
}, [date, format, show, showMeridian]);

const handleClick = (type: TimeType, d: number, event: React.MouseEvent) => {
Expand Down
4 changes: 2 additions & 2 deletions src/Cascader/DropdownMenu.tsx
Expand Up @@ -78,9 +78,9 @@ const DropdownMenu: RsRefForwardingComponent<'div', DropdownMenuProps> = React.f
}

if (activeItem) {
const position = getPosition(activeItem, column)!;
const position = getPosition(activeItem, column);
// Let the active option scroll into view.
scrollTop(column, position.top);
scrollTop(column, position?.top);
}
});
}, [prefix]);
Expand Down
26 changes: 14 additions & 12 deletions src/CheckTreePicker/CheckTreePicker.tsx
Expand Up @@ -122,14 +122,14 @@ const CheckTreePicker: PickerComponent<CheckTreePickerProps> = React.forwardRef(
placeholder,
value: controlledValue,
defaultValue = emptyArray,
defaultExpandAll,
defaultExpandAll = false,
disabledItemValues = emptyArray,
expandItemValues: controlledExpandItemValues,
defaultExpandItemValues,
defaultExpandItemValues = emptyArray,
height = 360,
menuStyle,
searchable = true,
virtualized,
virtualized = false,
className,
classPrefix = 'picker',
menuClassName,
Expand Down Expand Up @@ -286,15 +286,17 @@ const CheckTreePicker: PickerComponent<CheckTreePickerProps> = React.forwardRef(
};

const focusActiveNode = useCallback(() => {
focusToActiveTreeNode({
list: listRef.current!,
valueKey,
selector: `.${checkTreePrefix('node-active')}`,
activeNode,
virtualized: virtualized!,
container: treeViewRef.current!,
formattedNodes: getFormattedNodes()
});
if (listRef.current) {
focusToActiveTreeNode({
list: listRef.current,
valueKey,
selector: `.${checkTreePrefix('node-active')}`,
activeNode,
virtualized,
container: treeViewRef.current,
formattedNodes: getFormattedNodes()
});
}
}, [checkTreePrefix, activeNode, getFormattedNodes, valueKey, virtualized]);

useEffect(() => {
Expand Down