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

fix(index.tsx): make width and height properties optional in Size int… #797

Merged
merged 2 commits into from
Apr 25, 2024

Conversation

yushaku
Copy link
Contributor

@yushaku yushaku commented Dec 5, 2023

Proposed solution

  • currently Resizable get props defaultSize with width and height and must enter value for both of them

  • In update: make width and height properties optional in Size interface to allow for undefined values and it allow user set value for one of them

  • when i read and update the code, i realize that i can set "auto" for width and height, but i did not got it in any docs then, i think this make lib more flex to use

src/index.tsx Outdated
@@ -880,7 +874,7 @@ export class Resizable extends React.PureComponent<ResizableProps, State> {
}

updateSize(size: Size) {
this.setState({ width: size.width, height: size.height });
this.setState({ width: size.width || 'auto', height: size.height || 'auto' });
Copy link
Owner

Choose a reason for hiding this comment

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

Could you please use ?? instead of ||

Suggested change
this.setState({ width: size.width || 'auto', height: size.height || 'auto' });
this.setState({ width: size.width ?? 'auto', height: size.height ?? 'auto' });

src/index.tsx Outdated
@@ -870,7 +864,7 @@ export class Resizable extends React.PureComponent<ResizableProps, State> {
this.props.onResizeStop(event, direction, this.resizable, delta);
}
if (this.props.size) {
this.setState(this.props.size);
this.setState({ width: this.props.size.width || 'auto', height: this.props.size.height || 'auto' });
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
this.setState({ width: this.props.size.width || 'auto', height: this.props.size.height || 'auto' });
this.setState({ width: this.props.size.width ?? 'auto', height: this.props.size.height ?? 'auto' });

src/index.tsx Outdated
Comment on lines 392 to 393
width: this.propsSize?.width ? this.propsSize && this.propsSize.width : 'auto',
height: this.propsSize?.height ? this.propsSize && this.propsSize.height : 'auto',
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
width: this.propsSize?.width ? this.propsSize && this.propsSize.width : 'auto',
height: this.propsSize?.height ? this.propsSize && this.propsSize.height : 'auto',
width: this.propsSize?.width ?? 'auto',
height: this.propsSize?.height ?? 'auto',

@bokuweb
Copy link
Owner

bokuweb commented Apr 24, 2024

@yushaku Thanks for your PR.Sorry for late. Could you please update README.md too?

@yushaku
Copy link
Contributor Author

yushaku commented Apr 25, 2024

@bokuweb I updated it as you mentioned.

@bokuweb bokuweb merged commit bfd77aa into bokuweb:master Apr 25, 2024
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.

None yet

2 participants