From a42b128557e425a46d740ba2ed7cf1b53761b6e4 Mon Sep 17 00:00:00 2001 From: mertsincan Date: Mon, 12 Apr 2021 14:31:36 +0300 Subject: [PATCH] Refactor #1951 - For AutoComplete --- src/components/autocomplete/AutoComplete.d.ts | 2 ++ src/components/autocomplete/AutoComplete.js | 12 ++++++++++-- src/showcase/autocomplete/AutoCompleteDoc.js | 10 ++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/components/autocomplete/AutoComplete.d.ts b/src/components/autocomplete/AutoComplete.d.ts index 1133c69ed3..908dac3e18 100755 --- a/src/components/autocomplete/AutoComplete.d.ts +++ b/src/components/autocomplete/AutoComplete.d.ts @@ -92,6 +92,8 @@ interface AutoCompleteProps { onKeyPress?(event: React.KeyboardEvent): void; onContextMenu?(event: React.MouseEvent): void; onClear?(event: React.SyntheticEvent): void; + onShow?(): void; + onHide?(): void; } export class AutoComplete extends React.Component { } diff --git a/src/components/autocomplete/AutoComplete.js b/src/components/autocomplete/AutoComplete.js index dc6b6315da..f36dcdcf89 100644 --- a/src/components/autocomplete/AutoComplete.js +++ b/src/components/autocomplete/AutoComplete.js @@ -67,7 +67,9 @@ export class AutoComplete extends Component { onKeyUp: null, onKeyPress: null, onContextMenu: null, - onClear: null + onClear: null, + onShow: null, + onHide: null } static propTypes = { @@ -123,7 +125,9 @@ export class AutoComplete extends Component { onKeyUp: PropTypes.func, onKeyPress: PropTypes.func, onContextMenu: PropTypes.func, - onClear: PropTypes.func + onClear: PropTypes.func, + onShow: PropTypes.func, + onHide: PropTypes.func }; constructor(props) { @@ -299,6 +303,8 @@ export class AutoComplete extends Component { this.bindDocumentClickListener(); this.bindScrollListener(); this.bindResizeListener(); + + this.props.onShow && this.props.onShow(); } onOverlayExit() { @@ -309,6 +315,8 @@ export class AutoComplete extends Component { onOverlayExited() { ZIndexUtils.clear(this.overlayRef.current); + + this.props.onHide && this.props.onHide(); } alignOverlay() { diff --git a/src/showcase/autocomplete/AutoCompleteDoc.js b/src/showcase/autocomplete/AutoCompleteDoc.js index 1cbf37aaf4..127eb96b60 100644 --- a/src/showcase/autocomplete/AutoCompleteDoc.js +++ b/src/showcase/autocomplete/AutoCompleteDoc.js @@ -861,6 +861,16 @@ itemTemplate(item) { event: Browser event Callback to invoke when input is cleared by the user. + + onShow + - + Callback to invoke when overlay panel becomes visible. + + + onHide + - + Callback to invoke when overlay panel becomes hidden. +