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

Allow disabling of drag-based selection #204

Merged
merged 5 commits into from
May 25, 2018

Conversation

trabianmatt
Copy link
Contributor

Types of changes

What types of changes does your code introduce?

Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Description

We have a use case where we need to prevent the user from dragging to select a date range. This dragSelectionEnabled property, which is true by default, determines whether to allow drag-based selection.

We have a use case where we need to prevent the user from dragging to select a date range. This `dragSelectionEnabled` property, which is true by default, determines whether to allow drag-based selection.
Copy link
Collaborator

@mkg0 mkg0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pr 👍
I can merge after review fixes

@@ -165,6 +165,7 @@ export default class Main extends Component {
months={2}
ranges={[this.state.dateRangePicker.selection]}
direction="horizontal"
dragSelectionEnabled={false}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to show drag selection at examples. Can you remove it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep sorry for that - used during testing and accidentally committed. Removing!

disablePreview: true,
},
});
if (this.props.dragSelectionEnabled) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no need to wrap whole func with if condition again. You can add an or to L314

if (!drag.status || !this.props.dragSelectionEnabled) return;

onDragSelectionEnd(date) {
const { updateRange, displayMode, onChange, dragSelectionEnabled } = this.props;

if (dragSelectionEnabled) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no need to wrap whole func with if condition:

if (!dragSelectionEnabled) return;

@mkg0
Copy link
Collaborator

mkg0 commented May 24, 2018

Can you add it on readme too?

I used the "drag n drop" terminology from the top of the page, but feel free to change it if needed.
@mkg0 mkg0 merged commit 62e3123 into hypeserver:master May 25, 2018
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

Successfully merging this pull request may close these issues.

2 participants