Search results

Open the DatePicker popup upon focusing input of DatePicker in React DatePicker component

25 Jan 2022 / 1 minute to read

You can open the DatePicker popup on input focus by calling the show method in the input focus event.

The following example demonstrates how to open the DatePicker popup when the input is focused.

Copied to clipboard
// import the datepickercomponent
import { DatePickerComponent } from '@syncfusion/ej2-react-calendars';
import * as React from 'react';
import * as ReactDOM from 'react-dom';

export default class App extends React.Component<{}, {}> {

    public onFocus(args: FocusEventArgs){;

    public render() {
        return (
            // Specifies the tag for render the DatePicker component
            <DatePickerComponent focus={this.onFocus.bind(this)} placeholder="Choose a date" ref = {scope => {this.dateObj = scope }}/>

ReactDOM.render(<App />, document.getElementById('element'));