Skip to content

Fix calendar hover movement when using arrow keys in time input#47672

Open
pratibha-builds wants to merge 4 commits intojoomla:5.4-devfrom
pratibha-builds:fix-calendar-arrow-key-bug
Open

Fix calendar hover movement when using arrow keys in time input#47672
pratibha-builds wants to merge 4 commits intojoomla:5.4-devfrom
pratibha-builds:fix-calendar-arrow-key-bug

Conversation

@pratibha-builds
Copy link
Copy Markdown

Pull Request resolves #47649.

  • I read the Generative AI policy and my contribution is compatible with the policy and GNU/GPL 2 or later.

Summary of Changes

This PR fixes an issue where the calendar hover/selection state moves unexpectedly when using arrow keys (left/right) inside the time input field in the "Start Publishing" calendar.

The root cause was that the global calendar key event handler (_handleCalKeyEvent) was processing arrow key events even when the input field was focused. This caused unintended navigation of calendar dates while the user was only trying to move the cursor within the input.

The fix introduces a condition to ignore keyboard navigation when the active element is the input field:

  • If the input field is focused → do not process arrow key navigation
  • Otherwise → retain normal calendar keyboard navigation behavior

This ensures correct separation between input editing and calendar navigation.


Testing Instructions

  1. Go to Administrator → Content → Articles
  2. Create or edit any article
  3. Open the "Publishing" tab
  4. Click on the calendar icon for "Start Publishing"
  5. Select any date
  6. Click inside the input field (e.g. 2026-04-23 06:08:00)
  7. Use Left (←) and Right (→) arrow keys to move the cursor within the time

Actual result BEFORE applying this Pull Request

  • When pressing arrow keys inside the input field:

    • The cursor moves
    • BUT the calendar in the background also moves
  • The hover/selection jumps across dates unexpectedly

  • Leads to confusing and incorrect UI behavior

🎥 Before fix video:

beforefix.mp4

Expected result AFTER applying this Pull Request

  • When pressing arrow keys inside the input field:

    • Cursor moves correctly
    • **Calendar does NOT move **
  • Calendar remains stable while editing time

  • No regression in normal keyboard navigation when interacting with the calendar directly

🎥 After fix video:

afterfix.mp4

Documentation 1: Code Behavior Change

Updated _handleCalKeyEvent to ignore arrow key navigation when the active element is the input field.
This prevents unintended calendar movement while editing time values.

Documentation 2: UX Improvement

Improves user experience by ensuring that keyboard navigation inside input fields behaves independently from the calendar UI, avoiding unexpected interactions.

Documentation 3: Backward Compatibility
No breaking changes introduced
Existing calendar navigation remains unchanged
Fix is scoped only to input-focused scenarios

Link to documentations

Please select:

  • No documentation changes for guide.joomla.org needed
  • No documentation changes for manual.joomla.org needed

@joomla-cms-bot joomla-cms-bot added NPM Resource Changed This Pull Request can't be tested by Patchtester PR-5.4-dev labels Apr 23, 2026
if (active && active.closest && active.closest('.time')) {
return;
}
// 🔥 FINAL CLEAN FIX
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not add code comments which contain unicode symbols.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are typical of code comments from AI such as chatgpt

var H = makeTimePart("time time-hours form-control form-select", hrs, t12 ? 1 : 0, t12 ? 12 : 23, hoursCell),
M = makeTimePart("time time-minutes form-control form-select", mins, 0, 59, minutesCell),
AP = null;
// 🔥 FINAL FIX (attach individually)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not add code comments which contain unicode symbols.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are typical of code comments from AI such as chatgpt

@richard67
Copy link
Copy Markdown
Member

@pratibha-builds You are doing a lot of code style changes in your PR which are not related to the issue. Please revert that.

};

/** Method to handle keyboard click events **/
console.log("WORKING");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not add useless console log messages even if your AI told you to do it

Comment on lines +517 to +519
//ev.stopPropagation();
//ev.stopImmediatePropagation();
//ev.preventDefault(); // important for J5
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not add useless commented out code

@brianteeman
Copy link
Copy Markdown
Contributor

all the useless codestyle changes make it impossible to review

@brianteeman
Copy link
Copy Markdown
Contributor

I have tested this item 🔴 unsuccessfully on b5b9dad


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/47672.

@brianteeman
Copy link
Copy Markdown
Contributor

This does NOT work - see video and the indicator of the keypressed at the bottom

keyviz_v5Foo8mIdq.mp4

@pratibha-builds
Copy link
Copy Markdown
Author

all the useless codestyle changes make it impossible to review

Hi @brianteeman sorry for that unusual code style and for bug reproduction on console in the browser i have used console.log.
Now i have fixed it you can check the second one commit.

@brianteeman
Copy link
Copy Markdown
Contributor

Still does not work - have you actually tested this yourself? Maybe its me abd you can provide a video of it working

@pratibha-builds
Copy link
Copy Markdown
Author

pratibha-builds commented Apr 23, 2026 via email

@richard67
Copy link
Copy Markdown
Member

Hi @brianteeman sorry for that unusual code style and for bug reproduction on console in the browser i have used console.log. Now i have fixed it you can check the second one commit.

@pratibha-builds No. Your PR still contains a lot of unrelated code style changes. Please learn to check the result of your work on GitHub here: https://github.com/joomla/joomla-cms/pull/47672/changes

@brianteeman
Copy link
Copy Markdown
Contributor

@pratibha-builds i cant see any video

@pratibha-builds
Copy link
Copy Markdown
Author

Thanks for the feedback. I’ve updated the implementation and kept the changes minimal.

The issue is now resolved:

  • When interacting with the time dropdown (hours/minutes) and using the left or right arrow keys, the calendar no longer changes its hover state.
  • The selected date also remains stable and does not move unexpectedly.

Additionally, normal behavior is preserved:

  • Arrow keys still work correctly within the input field.
  • Dropdown controls function as expected without affecting the calendar.

Please let me know if any further adjustments are needed.

@muhme
Copy link
Copy Markdown
Contributor

muhme commented Apr 24, 2026

Please let me know if any further adjustments are needed.

@pratibha-builds There are pending review changes. Please merge them or comment on them and mark them as completed if they have already been implemented.

@brianteeman
Copy link
Copy Markdown
Contributor

absolutely zero positive changes to the functionality since my last tests. Do you even test your work!!

@pratibha-builds
Copy link
Copy Markdown
Author

absolutely zero positive changes to the functionality since my last tests. Do you even test your work!!

Hi @brianteeman i have tested it on my own system it was fully functional working also i have changed the code style.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NPM Resource Changed This Pull Request can't be tested by Patchtester PR-5.4-dev

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[5.4] Calendar hover state moves around when using arrow keys in the time input

6 participants