Fomantic-ui: [Calendar] Calendar is not opened again when clicking on input

Created on 7 Jun 2020  Â·  3Comments  Â·  Source: fomantic/Fomantic-UI

Bug Report

When the calendar input already has focus and the calendar isnt shown, clicking on the input again does not open the calendar. You have to un-focus the input and click it again to have the calendar shown.
I think clicking on the input should open the calendar, think of users accidently closing the calendar and trying to reopen it by clicking on the input field.
Or think of the calendar input as some date jumper in a calendar. You could use it several times in a row without focussing anything else than the input.

Steps to reproduce

  1. Go to https://fomantic-ui.com/modules/calendar.html#/definition
  2. Click the calendar input. The calendar opens.
  3. Click the calendar input again / select a date. The calendar closes.
  4. Click the calendar input again. The calendar does not open again.

Expected result

  1. Go to https://fomantic-ui.com/modules/calendar.html#/definition
  2. Click the calendar input. The calendar opens.
  3. Click the calendar input again / select a date. The calendar closes.
  4. Click the calendar input again. The calendar opens again.

Version

2.8.5

Browser: Chrome

lanjavascript typbug

All 3 comments

This is probably related to #1439 , because the additional click handler was removed there
@147loch Could you please look into this?

The default event listener for calendars based on an input field is focus. Adding on: 'click' to the calendar definition will make it work as you expected it to. (Sandbox)

The actual bug is that the calendar closes on a click where it should only close when the input is blurred.

The problem that my PR resolved was that the calendar module would setup multiple event listeners for focus, click, etc. and trigger multiple times. If the calendar is listening to focus events, then it should only open when the field is focused.

I apologize that I did not make this clearer in the PR, this should probably be added to the docs. I would probably argue that, for 2.9, the default event handler should be click and not focus. (i.e. this line). I can make a PR for this, also with a fix for the calendar dismissing on click even if the listened event should be focus.

@147loch Thanks for clarification! Yes, would be great if you could prepare PR(s) for that!

Was this page helpful?
0 / 5 - 0 ratings