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

openDirection in SingleDatePicker don't working #1166

Open
Andrevoks opened this issue May 14, 2018 · 9 comments
Open

openDirection in SingleDatePicker don't working #1166

Andrevoks opened this issue May 14, 2018 · 9 comments

Comments

@Andrevoks
Copy link

Andrevoks commented May 14, 2018

why openDirection don't working in SingleDatePicker, it works in DateRangePicker but in SingleDatePicker no

<SingleDatePicker
                    openDirection={"up"}
                    date={this.state.date}
                    isOutsideRange={() => false}
                    isDayHighlighted={day => isSameDay(moment(new Date()),moment(day))}
                    daySize={30}
                    verticalSpacing={2}
                    onDateChange={date => {
                        this.setState({ date });
                        if(date) {
                            this.props.onSaveValue(date.unix());
                        }
                    }}
                    displayFormat={this.props.dateFormat}
                    focused={this.state.focused}
                    numberOfMonths={1}
                    placeholder={this.props.dateFormat}
                    onFocusChange={({ focused }) =>{
                        this.setState({ focused });
                        this.props.isCalendarOpen(focused)
                    }}
                />

and i receive http://joxi.ru/BA05EMVhBg9xyr calendar which placed at bottom

@Andrevoks Andrevoks changed the title openDirection in SingleDatePicker openDirection in SingleDatePicker don't working May 14, 2018
@majapw
Copy link
Collaborator

majapw commented May 14, 2018

I wonder if it's an issue with verticalSpacing maybe. The openDirection prop seems to work on its own.
From the storybook: screen shot 2018-05-14 at 5 26 48 pm

@Andrevoks
Copy link
Author

yeah, story in story book it's working, but in my project,
17e748b906
i download react-dates demo check and it working, i set same version of react-dates in my project.... you see my screenshot

@Andrevoks
Copy link
Author

Andrevoks commented May 15, 2018

n-tile - google chrome_001
hmmm.... i added appendToBody={true} and it help, but calendar has strange position.
May openDirection need some other reqired params?

@Andrevoks
Copy link
Author

@majapw do you have some solution?

@majapw
Copy link
Collaborator

majapw commented May 18, 2018 via email

@Andrevoks
Copy link
Author

Andrevoks commented May 21, 2018

<SingleDatePicker date={this.state.date} // momentPropTypes.momentObj or null onDateChange={date => this.setState({ date })} focused={this.state.focused} // PropTypes.bool numberOfMonths={1} placeholder={"placeholder"} openDirection={"up"} onFocusChange={({ focused }) => this.setState({ focused })} />
3e16b337fa
@majapw I create other page with only datepicker, without css and props and receive same result.
react dates version in package.json
"react-dates": "^16.3.6"

@supra28
Copy link

supra28 commented Oct 16, 2018

@Andrevoks I'm having the same issue, where you able to solve this?

@Andrevoks
Copy link
Author

@supra28 we wrote own datepicker))

@Jony-Y
Copy link

Jony-Y commented Mar 19, 2019

@majapw Tried this as well. not working out of example. dont know why.

import React from 'react';
import { DateRangePicker } from 'react-dates';

const RangePicker = ({
  startDate,
  startDateId,
  endDateId,
  style,
  prevMonthButton,
  nextMonthButton,
  renderMonthElement,
  enableOutsideDays,
  isDayBlocked,
  isOutsideRange,
  verticalSpacing,
  disabled,
  endDate,
  readOnly,
  daySize,
  focusedInput,
  onFocus,
  numberOfMonths,
  minimumNights,
  onMonthChange,
  renderDayContents,
  initialVisibleMonth,
  onDatesChange,
  anchorDirection,
  openDirection,
}) => (
  <div style={style}>
    <DateRangePicker
      startDatePlaceholderText="Start date"
      endDatePlaceholderText={startDate ? '' : 'End date'}
      startDate={startDate}
      startDateId={startDateId}
      endDate={endDate}
      endDateId={endDateId}
      onDatesChange={onDatesChange}
      isDayBlocked={isDayBlocked}
      enableOutsideDays={enableOutsideDays}
      daySize={daySize}
      disabled={disabled}
      noBorder
      onNextMonthClick={onMonthChange}
      onPrevMonthClick={onMonthChange}
      numberOfMonths={numberOfMonths}
      hideKeyboardShortcutsPanel
      verticalSpacing={verticalSpacing}
      customArrowIcon={<div className={(startDate || endDate) ? 'text-black' : 'text-gray'}> - </div>}
      navPrev={prevMonthButton}
      navNext={nextMonthButton}
      renderMonthElement={renderMonthElement}
      focusedInput={focusedInput}
      onFocusChange={onFocus}
      readOnly={readOnly}
      minimumNights={minimumNights}
      renderDayContents={renderDayContents}
      isOutsideRange={isOutsideRange}
      initialVisibleMonth={initialVisibleMonth}
      anchorDirection={anchorDirection}
      openDirection={openDirection}
    />
  </div>
);

export default RangePicker;

Still not working.
using version 20.1.0

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

4 participants