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

Calendar: onSelect is forcing date while typing #7553

Closed
manuel-bitcraft opened this issue Jan 3, 2025 · 3 comments · Fixed by #7563
Closed

Calendar: onSelect is forcing date while typing #7553

manuel-bitcraft opened this issue Jan 3, 2025 · 3 comments · Fixed by #7563
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@manuel-bitcraft
Copy link

Describe the bug

Adding the onSelect callback (even an empy function) changes the typing behaviour for the date.

Reproducer

https://stackblitz.com/edit/dppelmek?file=src%2FApp.jsx

System Information

System:
    OS: Windows 11 10.0.22631
    CPU: (12) x64 13th Gen Intel(R) Core(TM) i7-1355U
    Memory: 41.48 GB / 63.64 GB
  Binaries:
    Node: 18.20.4 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.22 - C:\Program Files\nodejs\yarn.CMD
    npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (128.0.2739.67)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    primereact: ^10.8.5 => 10.8.5 
    react: ^18 => 18.2.0 
    tailwindcss: ^3.3.0 => 3.4.1

Steps to reproduce the behavior

Notes: using format dd/mm/yy
Objective: select date 15/01/2025 and then modify date to '15/11/2025' by typing

With onSelect commented out

  1. Select date 15/01/2025
  2. Place cursor after month (01)
  3. Press backspace twice so date reads '15//2025'
  4. type 1 so the date reads '15/1/2025'
  5. type 1 againg so date reads '15/11/2025'
  6. Success

With onSelect enabled as an empty callback

  1. Select date 15/01/2025
  2. Place cursor after month (01)
  3. Press backspace twice so date reads '15//2025'
  4. as soon as you type 1, the date changes to '15/01/2025' and the cursor is moved at the end
  5. if you try to delete the '0' for the '01' month (so I can type 1 to set the month to 11), the date stays to '15/01/2025' and the cursor is moved at the end
  6. Failed

Expected behavior

No response

@manuel-bitcraft manuel-bitcraft added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jan 3, 2025
@melloware melloware added Type: Bug Issue contains a defect related to a specific component. and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Jan 3, 2025
@melloware
Copy link
Member

looks like its related to this fix: #7121

@KumJungMin
Copy link
Contributor

KumJungMin commented Jan 4, 2025

  • I have checked the issue :)
  • As a result, I found that the same problem occurs in the previous version (v10.8.3) as well 😢
  • After investigating the cause of the issue, I discovered that the onSelect event is triggered when typing in the input field.

const onUserInput = (event) => {
updateValueOnInput(event, event.target.value);

issue occurred flow (Versions prior to v10.8.3)

graph TD
    A[User types in input field] --> B[onUserInput function is triggered]
    B --> C[updateValueOnInput function is triggered]
    C --> D[updateViewDate function is triggered]
    D --> E[onSelect function is triggered]
    E --> F["Issue occurred!!"] 
Loading

  • For now, I submitted a PR under the assumption that the onSelect function should only be triggered when clicking the date button.
  • This ensures that the onSelect function does not execute while the user is typing.
  • If the onSelect function is also expected to work while typing in the input field,
  • please leave a comment, and I will update it accordingly. Thank you! 😄

@melloware melloware added this to the 10.9.2 milestone Jan 4, 2025
@melloware
Copy link
Member

Nice it looks like this was introduced in #7155

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants