Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle date change (and ability to close) at minPanel level #63

Open
mvachette opened this issue Dec 18, 2018 · 1 comment
Open

Handle date change (and ability to close) at minPanel level #63

mvachette opened this issue Dec 18, 2018 · 1 comment

Comments

@mvachette
Copy link

I currently use "Picker" with minPanel prop to allow to display the component to select only years or months.

I have 2 issues with the actual implementation :

  • I cannot close the panel when my selection is done (closeOnSelectDay prop works only if dayPanel is the current one)
  • onChange is triggered each time I display a panel, even if the user does not make selection at all (ex navigatiin in years)

I propose to take care of the minPanel option to trigger change only when the min panel is the current one, and evaluate "closeOnSelect" under this condition.

Below is a diff of a possible implementation.
Are you open to a PR about this ?

//Trigger.jsx
handleChange = (moment, currentPanel) => {
-    const {closeOnSelectDay, onChange} = this.props;
+    const {closeOnSelectDay, onChange, minPanel = 'day'} = this.props;
 
-    if (currentPanel === 'day' && closeOnSelectDay) {
-      this.setState({
-        isOpen: false
-      });
-    }
+    if (currentPanel === minPanel {
+      if (closeOnSelectDay) {
+        this.setState({
+          isOpen: false
+        });
 
-    onChange && onChange(moment);
-  }
+        onChange && onChange(moment);
+      }
+   }
``
@smrsan76
Copy link

Hi @mvachette
I think this repository/package will not be active any more.

Please use this improved package and if that issue was still exist, report that issue to the improved package repo and help us making it better than before.

Thanks 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants