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

Commit 5618a4f

Browse files
authored
fix(Dropdown): check refs before focus (#2248)
* add checks * changelog
1 parent 7a1da89 commit 5618a4f

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
2424
### Fixes
2525
- Fix event listener leak in `FocusZone` @miroslavstastny ([#2227](https://github.com/microsoft/fluent-ui-react/pull/2227))
2626
- Fix styleParam to always be required in the styles functions @layershifter, @mnajdova ([#2235](https://github.com/microsoft/fluent-ui-react/pull/2235))
27+
- Check input and button refs exist before focus in `Dropdown` @silviuavram ([#2248](https://github.com/microsoft/fluent-ui-react/pull/2248))
2728

2829
### Features
2930
- Allow `useRef` hook used for storing debugging data to be defined in any order with other hooks in functional components @layershifter, @mnajdova ([#2236](https://github.com/microsoft/fluent-ui-react/pull/2236))

packages/react/src/components/Dropdown/Dropdown.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,13 +1286,13 @@ class Dropdown extends AutoControlledComponent<WithAsProp<DropdownProps>, Dropdo
12861286
}
12871287

12881288
tryFocusTriggerButton = () => {
1289-
if (!this.props.search) {
1289+
if (!this.props.search && this.buttonRef.current) {
12901290
this.buttonRef.current.focus()
12911291
}
12921292
}
12931293

12941294
tryFocusSearchInput = () => {
1295-
if (this.props.search) {
1295+
if (this.props.search && this.inputRef.current) {
12961296
this.inputRef.current.focus()
12971297
}
12981298
}

0 commit comments

Comments
 (0)