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

Remove invokation of responsivizePickerPosition from componentDidMount #183

Merged
merged 2 commits into from
Nov 18, 2016
Merged

Remove invokation of responsivizePickerPosition from componentDidMount #183

merged 2 commits into from
Nov 18, 2016

Conversation

Ikana
Copy link
Contributor

@Ikana Ikana commented Nov 16, 2016

This addressed the issue #181 on the storyboard, but should the method responsivizePickerPosition be invoked from an other method?

@coveralls
Copy link

Coverage Status

Coverage remained the same at 86.293% when pulling 2cd1555 on Ikana:fix-get-client-bounding-rect into 462c8bb on airbnb:master.

@majapw
Copy link
Collaborator

majapw commented Nov 16, 2016

This is not the correct solution. Based on my comment #181 (comment), let's change the responsivizePickerPosition in both files to be:

const { anchorDirection, horizontalMargin, withPortal, withFullScreenPortal } = this.props;
    const { dayPickerContainerStyles } = this.state;

    const isAnchoredLeft = anchorDirection === ANCHOR_LEFT;

    if (!withPortal && !withFullScreenPortal) {
      const containerRect = this.dayPickerContainer.getBoundingClientRect();
      const currentOffset = dayPickerContainerStyles[anchorDirection] || 0;
      const containerEdge = isAnchoredLeft ? containerRect[ANCHOR_RIGHT] : containerRect[ANCHOR_LEFT];

      this.setState({
        dayPickerContainerStyles: getResponsiveContainerStyles(
          anchorDirection,
          currentOffset,
          containerEdge,
          horizontalMargin
        ),
      });
    }

@ljharb
Copy link
Member

ljharb commented Nov 16, 2016

@Ikana please rebase on the command line so any merge commits are excised. Thanks!

@Ikana
Copy link
Contributor Author

Ikana commented Nov 16, 2016

I think I broke something the tests pass on my local repo.

@Ikana
Copy link
Contributor Author

Ikana commented Nov 17, 2016

I think it has to do with the recent update of react, the error is:

Error: Cannot find module 'react/lib/CSSPropertyOperations'

And on the blog post for 15.4.0 mentioned that the private apis did change

@ljharb
Copy link
Member

ljharb commented Nov 17, 2016

React 15.4 did break things; #184 will fix it.

@Ikana
Copy link
Contributor Author

Ikana commented Nov 17, 2016

so it wasn't me 😅

@ljharb
Copy link
Member

ljharb commented Nov 17, 2016

Nope! rebase and you should be set.

@@ -89,7 +89,6 @@ export default class SingleDatePicker extends React.Component {
/* istanbul ignore next */
componentDidMount() {
window.addEventListener('resize', this.responsivizePickerPosition);
this.responsivizePickerPosition();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you make the same change as you did in DateRangePicker here?

@majapw
Copy link
Collaborator

majapw commented Nov 17, 2016

Once you make the last change, can you squash all your commit into one and rebase on the latest master?

@Ikana
Copy link
Contributor Author

Ikana commented Nov 17, 2016

Sure thing

@ljharb ljharb added the semver-patch: fixes/refactors/etc Anything that's not major or minor. label Nov 17, 2016
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 86.271% when pulling 8451fb3 on Ikana:fix-get-client-bounding-rect into c108674 on airbnb:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 86.271% when pulling 8451fb3 on Ikana:fix-get-client-bounding-rect into c108674 on airbnb:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 86.271% when pulling 8451fb3 on Ikana:fix-get-client-bounding-rect into c108674 on airbnb:master.

window.addEventListener('resize', this.responsivizePickerPosition);
this.responsivizePickerPosition();
if (!withPortal && !withFullScreenPortal) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will not work on window resize still. Can you please update this file in the same way you did the DateRangePicker (ie put this check inside of the responsivizePickerPosition function instead of here)

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.6%) to 85.759% when pulling d057fb3 on Ikana:fix-get-client-bounding-rect into c108674 on airbnb:master.

@@ -1,5 +1,8 @@
# Change Log

## v4.0.2
Copy link
Member

Choose a reason for hiding this comment

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

@Ikana please do a rebase on the latest master rather than clicking "update branch", which creates a merge commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i am a little new to open source collaboration, do you know of a good tutorial on that, i thought i did it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @Ikana! Basically in your terminal you can run the following steps:

git checkout master
git pull airbnb master
git checkout fix-get-client-bounding-rect
git rebase master
git push -f origin fix-get-client-bound-rect

If you don't have airbnb configured as a remote branch, you'll have to do:

git remote add airbnb [email protected]:airbnb/react-dates.git

window.addEventListener('resize', this.responsivizePickerPosition);
this.responsivizePickerPosition();
if (!withPortal && !withFullScreenPortal) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't need this check here because we have it on line 293.

Ikana and others added 2 commits November 18, 2016 14:33
…ullScreenPortal are set to true

When either portal option is set, the DayPicker is not rendered at all
when hidden. What's more, it is centered on the screen and as a result
does not need to be moved based on its location relative to the edge of
the screen.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 86.159% when pulling 1ced2f8 on Ikana:fix-get-client-bounding-rect into 231342a on airbnb:master.

@majapw
Copy link
Collaborator

majapw commented Nov 18, 2016

@ljharb this should be good to go, can you do a last pass?

@Ikana
Copy link
Contributor Author

Ikana commented Nov 18, 2016

Hey @majapw thanks a lot for the patience and the help with git

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 86.159% when pulling b6246c6 on Ikana:fix-get-client-bounding-rect into 231342a on airbnb:master.

@majapw
Copy link
Collaborator

majapw commented Nov 18, 2016

No problem @Ikana! :D Thank you so much for the contribution. :)

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

LGTM

const containerRect = this.dayPickerContainer.getBoundingClientRect();
const currentOffset = dayPickerContainerStyles[anchorDirection] || 0;
const containerEdge =
isAnchoredLeft ? containerRect[ANCHOR_RIGHT] : containerRect[ANCHOR_LEFT];
Copy link
Member

Choose a reason for hiding this comment

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

can this line be moved to the previous one, so there's no linebreak after an assignment operator?

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 too long, and I preferred having the ternary on one line rather than splitting after the ?. Which do you think is better?

Copy link
Member

Choose a reason for hiding this comment

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

i always prefer a long line to arbitrary line breaks - ling length restrictions are always silly, and a poor proxy for readability.

const containerRect = this.dayPickerContainer.getBoundingClientRect();
const currentOffset = dayPickerContainerStyles[anchorDirection] || 0;
const containerEdge =
isAnchoredLeft ? containerRect[ANCHOR_RIGHT] : containerRect[ANCHOR_LEFT];
Copy link
Member

Choose a reason for hiding this comment

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

also here

@majapw majapw merged commit 283beb6 into react-dates:master Nov 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-patch: fixes/refactors/etc Anything that's not major or minor.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants