Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

fix(Tooltip): Fix page crash when content is null #2332

Merged
merged 4 commits into from
Feb 11, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Fixes
- Remove dependency on Lodash in TypeScript typings @layershifter ([#2323](https://github.com/microsoft/fluent-ui-react/pull/2323))
- Fix missing aria-describedby in AlertBehavior @delprzemo ([#2208](https://github.com/microsoft/fluent-ui-react/pull/2208))
- Fix page crash when `Tooltip` content is null @delprzemo ([#2332](https://github.com/microsoft/fluent-ui-react/pull/2332))
- Fix `document` usage in `mergeProviderContexts` to get SSR working @layershifter ([#2330](https://github.com/microsoft/fluent-ui-react/pull/2330))

### Features
Expand Down
2 changes: 2 additions & 0 deletions packages/react/src/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ export default class Tooltip extends AutoControlledComponent<TooltipProps, Toolt
overrideProps: this.getContentProps,
})

if (!tooltipContent) return null

return <Ref innerRef={this.contentRef}>{tooltipContent}</Ref>
}

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/utils/positioner/Popper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const Popper: React.FunctionComponent<PopperProps> = props => {
? children({ placement: computedPlacement, scheduleUpdate })
: (children as React.ReactElement)

return <Ref innerRef={contentRef}>{React.Children.only(child)}</Ref>
return child ? <Ref innerRef={contentRef}>{React.Children.only(child)}</Ref> : null
}

Popper.defaultProps = {
Expand Down