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

React/dp 12935 empty divs #510

Open
wants to merge 34 commits into
base: develop
Choose a base branch
from
Open

Conversation

smurrayatwork
Copy link
Contributor

Any PRs being created needs a changelog.txt file before being merged into dev. See: Change Log Instructions

Description

Related Issue / Ticket

Steps to Test

Screenshots

Use something like licecap to capture gifs to demonstrate behaviors.

Additional Notes:

Anything else to add?

Impacted Areas in Application

@todo

Today I learned...

}
}
InputSync.propTypes = {
formIds: PropTypes.arrayOf(PropTypes.string).isRequired,
Copy link
Contributor

Choose a reason for hiding this comment

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

add comments above these so they are rendered in documentation

}
}
InputLink.propTypes = {
formIds: PropTypes.arrayOf(PropTypes.string).isRequired,
Copy link
Contributor

Choose a reason for hiding this comment

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

add comments above these so they are rendered in documentation

const Form = (props) => {
const formContext = useContext(FormContext);
return(
<form className="ma__form-page" action="#">
Copy link
Contributor

Choose a reason for hiding this comment

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

just curious - i know this was there before - should the action be a passable prop with a default of #?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should yes!

// Update the inputs back to percentages when slider changes value.
inputSliderOptionsWithKnobs.updateFunc = (val) => {
const newVal = Number(numbro(val * 100).format({ mantissa: 0 }));
// We need to ensure that the new percentage value isn't already set on the Inputs we are changing.
Copy link
Contributor

Choose a reason for hiding this comment

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

what do you mean by "isn't already set" here?

@@ -24,9 +23,46 @@ class FormProvider extends Component {
hasId: this.hasId,
setValue: this.setValue,
updateState: this.updateState,
getValues: this.getValues
getValues: this.getValues,
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if these methods need to be in the state or can directly be passed to Provider value?

Copy link
Contributor

Choose a reason for hiding this comment

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

e.g.

Suggested change
getValues: this.getValues,
this.methods = {
getValue: this.getValue,
hasId: this.hasId,
setValue: this.setValue,
updateState: this.updateState,
getValues: this.getValues,
syncContent: this.syncContent,
getLinkedContent: this.getLinkedContent,
updateLinkedContent: this.updateLinkedContent,
setLinkedContent: this.setLinkedContent,
onUpdate: this.onUpdate,
getUpdateFunc: this.getUpdateFunc,
setUpdateFunc: this.setUpdateFunc
}

@@ -0,0 +1,63 @@
import React from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

add a story about this with documentation and use example

@@ -0,0 +1,79 @@
import React from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

add a story about this with documentation and use example

Copy link
Contributor

Choose a reason for hiding this comment

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

this is used in Form story

if (is.fn(this.context.syncContent)) {
this.context.syncContent(this.props.id);
}
}
getValue = () => this.state.value;
setValue = (value, afterUpdate) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

how is afterUpdate being used? can you add a description to this param?

@@ -36,19 +40,72 @@ class InputProvider extends React.Component {
super(props);
this.state = {
value: this.props.defaultValue,
linkedContent: this.props.linkedContent,
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add propTypes for Input and document all the props that Input/InputProvider expect?

// syncCondition is ran for each id passed in props.formIds from the Form component.
// This controls what happens for a single call to syncCondition.
// syncCondition overrides the default behavior in the else below.
if (is.fn(this.props.syncCondition)) {
Copy link
Contributor

@clairesunstudio clairesunstudio Mar 20, 2019

Choose a reason for hiding this comment

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

can you add syncCondition to propTypes and add description

formIds: PropTypes.arrayOf(PropTypes.string).isRequired,
children: PropTypes.any
};
InputSync.contextType = FormContext;
Copy link
Contributor

@clairesunstudio clairesunstudio Mar 20, 2019

Choose a reason for hiding this comment

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

Can we use useContext here?

Copy link
Contributor

Choose a reason for hiding this comment

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

oh nvm, can it only be used in functional component?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct.

componentDidMount() {
this.checkFormContext();
}
checkFormContext = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add comment about what checkFormContext is doing, and also in Input there's also checkFormContext but they are doing different things.

const { value } = this.context;
value[id].syncContent = [];
value[id].syncContent.push(this.syncContent);
this.context.updateState({ value });
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like this is updating Form context value? is it able to update the value if so can you provide an example?

Copy link
Contributor

Choose a reason for hiding this comment

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

ok got it this is pushing the syncContent function array to value in formContext so that if can be used to update its own state

getUpdateFunc: this.getUpdateFunc,
setUpdateFunc: this.setUpdateFunc,
getOverrideLink: this.getOverrideLink
};
formContext.updateState({ value });
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the purpose of updating form context methods from Input?

showError,
errorMsg,
value: toCurrency(newValue, countDecimals(props.step))
errorMsg
}, () => {
if (typeof props.onChange === 'function') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (typeof props.onChange === 'function') {
if (props.onChange && is.fn(props.onChange)) {

getValue = () => this.state.value;
setValue = (value, afterUpdate) => {
this.setState({ value }, afterUpdate);
getOwnRef = () => this.selfRef;
Copy link
Contributor

@clairesunstudio clairesunstudio Apr 3, 2019

Choose a reason for hiding this comment

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

how is this being used?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants