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

feat(@clayui/date-picker): add props to control expand functionality #3264

Merged
merged 1 commit into from
May 21, 2020

Conversation

bryceosterhaus
Copy link
Member

fixes #3262

Copy link
Member

@matuzalemsteles matuzalemsteles left a comment

Choose a reason for hiding this comment

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

LGTM!

@coveralls
Copy link

coveralls commented May 21, 2020

Pull Request Test Coverage Report for Build 111789209

  • 5 of 6 (83.33%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.02%) to 78.612%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/clay-date-picker/src/index.tsx 5 6 83.33%
Totals Coverage Status
Change from base Build 111757258: -0.02%
Covered Lines: 2372
Relevant Lines: 2810

💛 - Coveralls

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 21, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 1ec1255:

Sandbox Source
practical-dream-j0tdl Configuration
elegant-river-bjhi8 Configuration

@bryceosterhaus bryceosterhaus changed the title feat(@clayui/date-picker): add prop to close dropdown when date is selected feat(@clayui/date-picker): add props to control expand functionality May 21, 2020
Comment on lines 252 to 264
const setExpanded = (val: boolean) => {
if (expanded !== val && onExpandedChange) {
onExpandedChange(val);
}

setInternalExpanded(val);
};

React.useEffect(() => {
if (expanded !== undefined) {
setInternalExpanded(expanded);
}
}, [expanded]);
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we can decrease the use here of useEffect which could happen a double rendering due to the useState that the developer will have to use to control. I'm thinking of something like this:

const expanded = externalExpanded !== undefined ? externalExpanded : internalExpanded;
const setExpanded = onExpandedChange ? onExpandedChange : setInternalExpanded;

externalExpanded can only be an alias of expanded prop. What do you think? it's makes sense for you?

Copy link
Member Author

Choose a reason for hiding this comment

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

@matuzalemsteles let me try that out. That was my goal but my first iteration was having issues. Let me look again to see if this is possible.

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.

Hide date picker after selecting date
3 participants