EasyUI Forum
November 30, 2022, 09:19:06 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Issue: DateBox onFocus fires twice  (Read 160 times)
chrwei
Full Member
***
Posts: 219


View Profile Email
« on: November 07, 2022, 01:18:43 PM »

When clicking a datebox, the onFocus even fires twice, and fires another 2 times when either closing the drop down or selecting a date, which really it shouldn't fire at all for those actions.

Example:

Code:
import React from 'react';
import { DateBox } from 'rc-easyui';
 
class App extends React.Component {
    constructor() {
        super();
        this.state = {
            value: new Date(),
        }
        this.times = React.createRef();
        this.times.current = 0;
    }
    formatDate(date) {
        let y = date.getFullYear();
        let m = date.getMonth() + 1;
        let d = date.getDate();
        return [m, d, y].join('/')
    }
    handleChange(value) {
        this.setState({ value: value })
    }
    handleFocus(){
      console.log("focus",this.times.current)
      this.times.current++;
    }
    render() {
        return (
            <div>
                <h2>Restrict Date Range in DateBox</h2>
                <p>This example shows how to restrict the user to select only ten days from now.</p>
                <DateBox
                    panelStyle={{ width: 250, height: 300 }}
                    editable={false}
                    value={this.state.value}
                    onChange={this.handleChange.bind(this)}
                    onFocus={this.handleFocus.bind(this)}
                />
                <p>{this.formatDate(this.state.value)}</p>
            </div>
        );
    }
}
 
export default App;
Logged
jarry
Administrator
Hero Member
*****
Posts: 2140


View Profile Email
« Reply #1 on: November 08, 2022, 05:34:10 PM »

Please try to update to the newest version.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!