fix(SFDC): fix React error in tokenizing text field

Summary:
Get ready for some SFDC diffs! Hooray getting more eyeballs on SFDC. At
this stage it's a lot of FYI to hopefully start showing more people parts
of the SFDC plugin.

This is related to the form you use to create new Salesforce Objects with.

The form window basically looks like:
```
<SalesforceObjectFormWithWindowProps>
  <SalesforceObjectForm>
    <GeneratedForm>
      <GeneratedFieldset>
        <FormItem type="input" />
        <FormItem type="email" />
        ... (lots of FormItems)
        <SalesforceObjectPicker>
          <TokenizingTextField>
            <Menu>
              some placeholder that had an error fixed by this diff!!!
            </Menu>
          </TokenizingTextField>
        </SalesforceObjectPicker>
        <FormItem type="checkbox" />
      </GeneratedFieldset>
    </GeneratedForm>
  </SalesforceObjectForm>
</SalesforceObjectFormWithWindowProps>
```

The whole GeneratedForm is controlled by an obejct called `formData`. This
is documented in `GeneratedForm`.

This bug prevented me from properly using SalesforceObjectPickers inside
my form.

Test Plan: manual

Reviewers: mark, halla, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3935
This commit is contained in:
Evan Morikawa 2017-02-16 12:36:06 -08:00
parent 3837e165c3
commit ebac4275cb
2 changed files with 5 additions and 4 deletions

2
src/K2

@ -1 +1 @@
Subproject commit c0bdeb53dcdca446746178640047de4a2443bf27
Subproject commit f27ac0d6c0d7acf625dce5547e2d23f6c455a81a

View file

@ -394,9 +394,10 @@ export default class TokenizingTextField extends React.Component {
componentWillReceiveProps(newProps) {
if (this.props.tokens.length === 0 && this.state.inputValue.length === 0) {
this.setState({inputValue: newProps.defaultValue});
if (newProps.defaultValue && newProps.defaultValue.length > 0) {
this._refreshCompletions(newProps.defaultValue);
const newDefaultValue = newProps.defaultValue || ""
this.setState({inputValue: newDefaultValue});
if (newDefaultValue.length > 0) {
this._refreshCompletions(newDefaultValue);
}
}
}