Skip to content

Commit 4edccde

Browse files
committed
Add onFocus, onBlur, onMouseEnter and onMouseLeave events to Dropdown
1 parent c6e0d7d commit 4edccde

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- **Dropdown** `onFocus`, `onBlur`, `onMouseEnter` and `onMouseLeave` props.
13+
1014
## [9.145.2] - 2021-10-26
1115

1216
### Fixed

react/components/Dropdown/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ options = [
3737
options={options}
3838
value={state.selected1}
3939
onChange={(_, v) => setState({ selected1: v })}
40+
onFocus={() => console.log('onFocus fired!')}
41+
onBlur={() => console.log('onBlur fired!')}
42+
onMouseEnter={() => console.log('onMouseEnter fired!')}
43+
onMouseLeave={() => console.log('onMouseLeave fired!')}
4044
/>
4145
</div>
4246

@@ -46,6 +50,10 @@ options = [
4650
options={options}
4751
value={state.selected2}
4852
onChange={(_, v) => setState({ selected2: v })}
53+
onFocus={() => console.log('onFocus fired!')}
54+
onBlur={() => console.log('onBlur fired!')}
55+
onMouseEnter={() => console.log('onMouseEnter fired!')}
56+
onMouseLeave={() => console.log('onMouseLeave fired!')}
4957
/>
5058
</div>
5159

@@ -56,6 +64,10 @@ options = [
5664
options={options}
5765
value={state.selected3}
5866
onChange={(_, v) => setState({ selected3: v })}
67+
onFocus={() => console.log('onFocus fired!')}
68+
onBlur={() => console.log('onBlur fired!')}
69+
onMouseEnter={() => console.log('onMouseEnter fired!')}
70+
onMouseLeave={() => console.log('onMouseLeave fired!')}
5971
/>
6072
</div>
6173
</div>

react/components/Dropdown/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ class Dropdown extends Component {
7575

7676
handleFocus = () => {
7777
this.setState({ active: true })
78+
this.props.onFocus && this.props.onFocus(event)
7879
}
7980

8081
handleBlur = () => {
8182
this.setState({ active: false })
83+
this.props.onBlur && this.props.onBlur(event)
8284
}
8385

8486
getValueLabel() {
@@ -219,6 +221,8 @@ class Dropdown extends Component {
219221
onChange={this.handleChange}
220222
onFocus={this.handleFocus}
221223
onBlur={this.handleBlur}
224+
onMouseEnter={this.props.onMouseEnter}
225+
onMouseLeave={this.props.onMouseLeave}
222226
ref={this.props.forwardedRef}
223227
// Check the comment on the constructor regarding nil values
224228
value={value == null ? '' : value}
@@ -324,6 +328,14 @@ Dropdown.propTypes = {
324328
required: PropTypes.bool,
325329
/** onChange event */
326330
onChange: PropTypes.func,
331+
/** onFocus event */
332+
onFocus: PropTypes.func,
333+
/** onBlur event */
334+
onBlur: PropTypes.func,
335+
/** onMouseEnter event */
336+
onMouseEnter: PropTypes.func,
337+
/** onMouseLeave event */
338+
onMouseLeave: PropTypes.func,
327339
/** onClose event */
328340
onClose: PropTypes.func,
329341
/** onOpen event */

styleguide.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,12 @@ module.exports = {
287287
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
288288
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
289289
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
290-
})(window,document,'script','dataLayer','GTM-M4WMB9F');</script>
290+
})(window,document,'script','dataLayer','GTM-NCDTF39');</script>
291291
<!-- End Google Tag Manager -->`,
292292
},
293293
body: {
294294
raw: `<!-- Google Tag Manager (noscript) -->
295-
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M4WMB9F"
295+
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NCDTF39"
296296
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
297297
<!-- End Google Tag Manager (noscript) -->`,
298298
},

0 commit comments

Comments
 (0)