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

Multiple Select: setValue method does not execute select change event #1938

Closed
Nurai1 opened this issue Sep 14, 2023 · 4 comments · Fixed by #2149
Closed

Multiple Select: setValue method does not execute select change event #1938

Nurai1 opened this issue Sep 14, 2023 · 4 comments · Fixed by #2149
Assignees
Labels
Milestone

Comments

@Nurai1
Copy link

Nurai1 commented Sep 14, 2023

Describe the bug
Multiple Select setValue method does not execute neither select change event nor custom 'valueChange.te.select' event.

To Reproduce
Steps to reproduce the behavior:

  1. Create Multiple Select via tw-elements like in the example docs.
  2. Create some button where you programmatically set values for select.
  3. Create event listener on select
  4. Programmatically set values for select via button and check that event haven't executed.

Expected behavior
Change Event executed after setValue.

@juujisai
Copy link
Contributor

Hi, thanks for letting us know. I'm adding this to our list

@juujisai juujisai added this to the v1.1.0 milestone Sep 15, 2023
@juujisai juujisai added the bug label Sep 15, 2023
@azica
Copy link

azica commented Nov 5, 2023

please tell me how i can get value of datepicker?

@iprzybysz
Copy link
Contributor

iprzybysz commented Nov 6, 2023

Hi @azica, it would be awesome if you could post your questions in a separate issue. That way, we can give you the best help possible.

@iprzybysz
Copy link
Contributor

please tell me how i can get value of datepicker?

To achieve this, you can use input event. Here is an example code:

<div
  class="relative mb-3"
  data-te-datepicker-init
  data-te-input-wrapper-init
  >
   <input
     id="my-input"
     type="text"
     class="peer block min-h-[auto] w-full rounded border-0 bg-transparent px-3 py-[0.32rem] leading-[1.6] outline-none transition-all duration-200 ease-linear focus:placeholder:opacity-100 peer-focus:text-primary data-[te-input-state-active]:placeholder:opacity-100 motion-reduce:transition-none dark:text-neutral-200 dark:placeholder:text-neutral-200 dark:peer-focus:text-primary [&:not([data-te-input-placeholder-active])]:placeholder:opacity-0"
     placeholder="Select a date" />
   <label
     for="floatingInput"
     class="pointer-events-none absolute left-3 top-0 mb-0 max-w-[90%] origin-[0_0] truncate pt-[0.37rem] leading-[1.6] text-neutral-500 transition-all duration-200 ease-out peer-focus:-translate-y-[0.9rem] peer-focus:scale-[0.8] peer-focus:text-primary peer-data-[te-input-state-active]:-translate-y-[0.9rem] peer-data-[te-input-state-active]:scale-[0.8] motion-reduce:transition-none dark:text-neutral-200 dark:peer-focus:text-primary"
     >Select a date</label>
</div>

// JS
// Initialization for ES Users
import { Datepicker, Input, initTE } from "tw-elements";

initTE({ Datepicker, Input });

const myInput = document.getElementById("my-input");
myInput.addEventListener("input", (e) => {
  console.log(e.target.value);
});

@Trochonovitz Trochonovitz linked a pull request Nov 20, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants