Skip to content
This repository has been archived by the owner on Dec 23, 2022. It is now read-only.

Form submission should be prevented of onBeforeAdd prevented chip creation #327

Open
theKashey opened this issue Jul 20, 2020 · 2 comments

Comments

@theKashey
Copy link

Scenario

  • you enter for example 123
  • you have onBeforeAdd to accept only 6 characters
  • it returns false
  • chip is not created
  • form is submitted

I am referring to this piece of code:
https://github.com/TeamWertarbyte/material-ui-chip-input/blob/master/src/ChipInput.js#L391-L394

should be

 handleAddChip (chip) {
    if (this.props.onBeforeAdd && !this.props.onBeforeAdd(chip)) {
      this._preventChipCreation = true
      return chip ? true : false; // -> allow default only if there is no chip to add
    }
@leMaik
Copy link
Member

leMaik commented Sep 8, 2020

Good suggestion, PR welcome @theKashey :)

@ghost
Copy link

ghost commented Jan 22, 2021

Hi guys, is it ok if I open this PR since it's inactive since September 2020? I'm really needing this fix. Thank you.

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

No branches or pull requests

2 participants