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

Issue with adding new list items #16

Closed
guciek27 opened this issue May 31, 2016 · 13 comments
Closed

Issue with adding new list items #16

guciek27 opened this issue May 31, 2016 · 13 comments
Assignees
Labels
Type: Bug Bug reports and their fixes

Comments

@guciek27
Copy link

I have an issue with adding new list items when using autosave={true} on the form. It is fine that the form is validated when new item is attached but at the moment the item does not attach on the first click.

Please have a look at the attached gif below that should explain the issue. Keep in mind that I'm clicking twice on the + icon before new items appear:
kb2fp827mt

@radekmie
Copy link
Contributor

Thanks for pointing it out. I'll look at it later.

@radekmie radekmie self-assigned this May 31, 2016
@radekmie radekmie added the Type: Bug Bug reports and their fixes label May 31, 2016
@radekmie
Copy link
Contributor

I've tried, but I can't reproduce it. Could you show the code?

@guciek27
Copy link
Author

This is the simplified version of the code.

<AutoForm schema={ userProfileSchema } autosave={ true } onSubmit={ doc => console.log(doc) }>
  <TextField
    error="First name is required"
    name="name.first"
    placeholder="First Name"
  />
  <TextField
    error="Last name is required"
    name="name.last"
    placeholder="Last Name"
  />

  <ListField name="contactEmails" initialCount={1}>
    <ListItemField name="$">
      <TextField name="address" placeholder="Email address" />
    </ListItemField>
  </ListField>
  <ErrorsField />
</AutoForm>

@serkandurusoy
Copy link
Contributor

Hmm, this may be related to the fact that contactEmails is possibly optional with no initial value defined (so its internal expected initial count is 0) but we explicitly provide an initialCount property that is higher

so to summarize, I think this may be an apparent issue with

  • array is optional and we have initial count
  • array min count is less than intial count

@radekmie
Copy link
Contributor

radekmie commented May 31, 2016

Hah! It's not that, @serkandurusoy. It's not even a bug. If you look carefully, you'll see, that not the badge itself has an onClick event, but only the icon. It should work in 1.0.0-rc.11.

@serkandurusoy
Copy link
Contributor

ooh! wow, good catch!

@serkandurusoy
Copy link
Contributor

@radekmie that might not have been it afterall.

If you watch the gif carefully, the first click registers and fires off validation! so it is not a click target problem. the second click then creates the new input

furthermore, this is not a bootstrap-3/4 input but based on the unstyled and your commit changes bootstrap versions, but the unstyled does not seem to have that wrong placement of click handler anyway.

@radekmie
Copy link
Contributor

I don't think, that validate is being called - those fields, that @guciek27 posted, have constant errors. All in all - if this issue is still a problem, please, comment, and I'll reopen this issue.

@serkandurusoy
Copy link
Contributor

I tested this. It does not matter about the error being there all along. I can introduce a new error and still reproduce the issue.

  1. make sure there is an error, you can create it by clearing a required field
  2. click on + for a list (nothing happens)
  3. click again and an input is added

it is even more evident when you start with an empty form that has required fields that are empty to begin with.

the first clicks on the + signs don't create an input, but fires off validation (the form is autosave=true if you think it matters)

@radekmie
Copy link
Contributor

Okay, I'll dig into it tomorrow.

@radekmie radekmie reopened this May 31, 2016
@radekmie
Copy link
Contributor

radekmie commented Jun 1, 2016

Problem was in ListAddField, not ListField - its initialCount was undefined, but it should be passed from ListField. Fixed in 1.0.0-rc.12 (I hope).

@serkandurusoy
Copy link
Contributor

Thank you @radekmie I'll test this as soon as I can and let you know.

Sent from my iPhone

On Jun 1, 2016, at 17:42, "Radosław Miernik" notifications@github.com
wrote:

Problem was in ListAddField, not ListField - its initialCount was
undefined, but it should be passed from ListField. Fixed in 1.0.0-rc.12 (I
hope).


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#16 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AEbz3A7FmrC0nb0BpWgCZkh0tJTMsesgks5qHZpWgaJpZM4Iqe7T
.

@serkandurusoy
Copy link
Contributor

this works now! thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Bug reports and their fixes
Projects
Archived in project
Development

No branches or pull requests

3 participants