-
Notifications
You must be signed in to change notification settings - Fork 678
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
Allow disabling of drag-based selection #204
Conversation
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.
There was a problem hiding this 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
demo/src/components/Main.js
Outdated
@@ -165,6 +165,7 @@ export default class Main extends Component { | |||
months={2} | |||
ranges={[this.state.dateRangePicker.selection]} | |||
direction="horizontal" | |||
dragSelectionEnabled={false} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
src/components/Calendar.js
Outdated
disablePreview: true, | ||
}, | ||
}); | ||
if (this.props.dragSelectionEnabled) { |
There was a problem hiding this comment.
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;
src/components/Calendar.js
Outdated
onDragSelectionEnd(date) { | ||
const { updateRange, displayMode, onChange, dragSelectionEnabled } = this.props; | ||
|
||
if (dragSelectionEnabled) { |
There was a problem hiding this comment.
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;
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.
Types of changes
What types of changes does your code introduce?
Put an
x
in the boxes that applyDescription
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.