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

Can not clear/ override the input value in v 1.0.3 #104

Open
olgaplaga opened this issue Dec 8, 2022 · 20 comments
Open

Can not clear/ override the input value in v 1.0.3 #104

olgaplaga opened this issue Dec 8, 2022 · 20 comments

Comments

@olgaplaga
Copy link

There is currently no way to clear the input value before the email is transformed into the tile.

The value is set while someone writes inside an input before the email address is finished and converted to the tile.
At this moment, when I want to create for e.g an action button, that clears input from unfinished emails like this:

const input: HTMLInputElement | null = document.querySelector('.react-multi-email input')

input.value = '' // this will not work

This will not work, because the package overrides this process with the value. Please provide an option to clear the input from value.

@ojaspatharkar-qure
Copy link

same here. need provision to clear the input.

@LoveWithCoding
Copy link

@ojaspatharkar-qure , @olgaplaga Ddi you find the solution?

@ojaspatharkar-qure
Copy link

@ojaspatharkar-qure , @olgaplaga Ddi you find the solution?

have you tried using onChangeInput props?

@Yandamuri
Copy link

@ojaspatharkar-qure , @olgaplaga Ddi you find the solution?

have you tried using onChangeInput props?

onChangeInput gives what ever we type(letter by letter). Can we remove input by using this prop?

@hovelopin
Copy link
Contributor

@LoveWithCoding hello,

Can you confirm if I understand this correctly?

Is this the issue where it doesn't work when I create a button externally and try to control the input value?

@Yandamuri
Copy link

Yandamuri commented Jul 17, 2024

@hovelopin

let say if i type correct email and press tab then it will be shown as chip(with some background color). but some times user might leave the filed with half typed value which is any way not a valid email. In such a cases i want to remove the half typed value on OnBlur event. I do not want fields contain unfinished emails.

Is there a way to achieve this?

@thomasJang
Copy link
Member

thomasJang commented Jul 17, 2024

@hovelopin

I just made a PR. PLZ review my code.
I thought a new PROP was needed to control INPUT values in the component. It can be used as in the following example.

const [input, setInput] = useState<string>('');

return (
        <ReactMultiEmail
          inputValue={input}
          onChangeInput={value => {
            console.log(value);
            setInput(value);
          }}
          onBlur={() => {
            setInput('');
          }}
        />
);

@Yandamuri
Copy link

@hovelopin

I just made a PR. PLZ review my code. I thought a new PROP was needed to control INPUT values in the component. It can be used as in the following example.

const [input, setInput] = useState<string>('');

return (
        <ReactMultiEmail
          inputValue={input}
          onChangeInput={value => {
            console.log(value);
            setInput(value);
          }}
          onBlur={() => {
            setInput('');
          }}
        />
);

Exactly. this what I am looking for.

@thomasJang
Copy link
Member

thomasJang commented Jul 17, 2024

Now, you can use 1.0.24

It can be used as in the following example.

const [input, setInput] = useState<string>('');

return (
        <ReactMultiEmail
          inputValue={input}
          onChangeInput={value => {
            console.log(value);
            setInput(value);
          }}
          onBlur={() => {
            setInput('');
          }}
        />
);

@Yandamuri
Copy link

@thomasJang Thank you for this quick response. This solved the problem discussed here, but got new issue.

Screen.Recording.2024-07-17.at.5.04.01.PM.mov

when email is validated(When tapped on tab bar), email field renders redundant emails because of new prop inputValue. Is it possible to prevent rendering the inputValue once email is validated.

@thomasJang
Copy link
Member

@Yandamuri
Could you share your code?

@Yandamuri
Copy link

@thomasJang

const MultiEmail = () => {
    const [tempInput, setTempInput] = useState('');
    const [emails, setEmails] = useState([]);

    return (
        <ReactMultiEmail
            placeholder="Type here"
            emails={emails}
            inputValue={tempInput}
            onChange={(emails) => setEmails(emails)}
            onChangeInput={(value) => setTempInput(value)}
            onBlur={() => setTempInput('')}
            getLabel={(email, index, removeEmail) => {
                return (
                    <div data-tag key={index}>
                        {email}
                        <span data-tag-handle onClick={() => removeEmail(index)}>×</span>
                    </div>
                );
            }}
        />
    );
}

@thomasJang
Copy link
Member

@Yandamuri
https://codesandbox.io/p/sandbox/react-multi-email-test-f79zn2

I don't think there's a problem when I check it on the link. Check it out.

@Yandamuri
Copy link

@thomasJang
Still issue persists in the link you provided. I am not sure if understood the problem from my previous comment. Problem is redundant emails and it still exists.

[

Screen.Recording.2024-07-18.at.8.55.01.AM.mov

](url)

OR Please correct me if i am missing something.

@thomasJang
Copy link
Member

Are you using Windows?
And did you enter the tab key after entering the email?

@hovelopin
Copy link
Contributor

hovelopin commented Jul 18, 2024

@Yandamuri did you press space?

@thomasJang
Copy link
Member

@Yandamuri
I've fixed the code. I'll let you know when it's distributed.
#178

@Yandamuri
Copy link

Are you using Windows? And did you enter the tab key after entering the email?

I am using MacBook and of course I pressed space bar(not the tab key).

@thomasJang
Copy link
Member

Now, you can use 1.0.25 @Yandamuri

@Yandamuri
Copy link

@thomasJang Yes, It's working as expected. Thank you so much for your effort and prompt response.

It would be great if the README.md and version change logs are updated regarding these new changes. Please be notified that package version is still showing as 1.0.17 only

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

No branches or pull requests

6 participants