Skip to content

Commit

Permalink
Refactor #1951 - For AutoComplete
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Apr 12, 2021
1 parent 8c081f3 commit a42b128
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/components/autocomplete/AutoComplete.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ interface AutoCompleteProps {
onKeyPress?(event: React.KeyboardEvent<HTMLInputElement>): void;
onContextMenu?(event: React.MouseEvent<HTMLElement>): void;
onClear?(event: React.SyntheticEvent): void;
onShow?(): void;
onHide?(): void;
}

export class AutoComplete extends React.Component<AutoCompleteProps, any> { }
12 changes: 10 additions & 2 deletions src/components/autocomplete/AutoComplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -299,6 +303,8 @@ export class AutoComplete extends Component {
this.bindDocumentClickListener();
this.bindScrollListener();
this.bindResizeListener();

this.props.onShow && this.props.onShow();
}

onOverlayExit() {
Expand All @@ -309,6 +315,8 @@ export class AutoComplete extends Component {

onOverlayExited() {
ZIndexUtils.clear(this.overlayRef.current);

this.props.onHide && this.props.onHide();
}

alignOverlay() {
Expand Down
10 changes: 10 additions & 0 deletions src/showcase/autocomplete/AutoCompleteDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,16 @@ itemTemplate(item) {
<td>event: Browser event</td>
<td>Callback to invoke when input is cleared by the user.</td>
</tr>
<tr>
<td>onShow</td>
<td>-</td>
<td>Callback to invoke when overlay panel becomes visible.</td>
</tr>
<tr>
<td>onHide</td>
<td>-</td>
<td>Callback to invoke when overlay panel becomes hidden.</td>
</tr>
</tbody>
</table>
</div>
Expand Down

0 comments on commit a42b128

Please sign in to comment.