ICEfaces
  1. ICEfaces
  2. ICE-8829

Pressing enter on inputText causes ice:selectInputDate calendar to pop up

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.2, EE-1.8.2.GA_P05
    • Fix Version/s: EE-3.2.0.GA, EE-1.8.2.GA_P06, 3.3
    • Component/s: ICE-Components
    • Labels:
      None
    • Environment:
      ICEfaces 1.8.2.GA_P05, ICEfaces 1.8.2
      Browsers: Firefox, Chrome, IE

      Description

      To reproduce:
      1) Deploy attached test application
      2) Focus on one of the input fields and press ENTER
      The Popup Calendar will appear


      See forum reference for more details.

        Activity

        Hide
        Arturo Zambrano added a comment -

        I also noticed that the image input doesn't support an onfocus event, or for some reason it's not firing that event.

        Anyway, I found a quirk in the way browsers fire this artificial click event on the image input. When you press 'enter' on the text field, two different event objects are created: the keyboard event and an artificial click event on the image input. However, I noticed that no onmousedown nor onmouseup events are artificially fired. So, when you actually click on the image, you'll see onmousedown and onmouseup fired first, before the click event, but when you press 'enter' on the text field, you'll only see the artificial click event being fired. So, we could take advantage of this and set a flag either onmousedown or onmouseup to indicate that it is a real click. Then, from the onclick event, we check if this flag is present. If it is, we proceed normally and then remove the flag at the end. If the flag is not present, then we know it's an artificial click event and we ignore it. This is very atomic, so we wouldn't have to worry about the node being replaced.

        Show
        Arturo Zambrano added a comment - I also noticed that the image input doesn't support an onfocus event, or for some reason it's not firing that event. Anyway, I found a quirk in the way browsers fire this artificial click event on the image input. When you press 'enter' on the text field, two different event objects are created: the keyboard event and an artificial click event on the image input. However, I noticed that no onmousedown nor onmouseup events are artificially fired. So, when you actually click on the image, you'll see onmousedown and onmouseup fired first, before the click event, but when you press 'enter' on the text field, you'll only see the artificial click event being fired. So, we could take advantage of this and set a flag either onmousedown or onmouseup to indicate that it is a real click. Then, from the onclick event, we check if this flag is present. If it is, we proceed normally and then remove the flag at the end. If the flag is not present, then we know it's an artificial click event and we ignore it. This is very atomic, so we wouldn't have to worry about the node being replaced.
        Hide
        yip.ng added a comment - - edited

        Doesn't work because when you press enter or space bar while the button has focus, it doesn't generate mousedown or mouseup events either. See video http://screencast.com/t/gD3SfC2W.

        Show
        yip.ng added a comment - - edited Doesn't work because when you press enter or space bar while the button has focus, it doesn't generate mousedown or mouseup events either. See video http://screencast.com/t/gD3SfC2W .
        Hide
        Ken Fyten added a comment -

        If you expand on Art's suggestion, and also add listeners for space/enter keydown events on the image button, that would also set the "real event" flag, that might cover the keyboard use cases as well.

        Show
        Ken Fyten added a comment - If you expand on Art's suggestion, and also add listeners for space/enter keydown events on the image button, that would also set the "real event" flag, that might cover the keyboard use cases as well.
        Hide
        yip.ng added a comment -

        Done. Notes:

        • onmousedown: need to check for left click (right click does not popup)
        • onkeydown: need to check for enter and space bar (otherwise tab also sets flag)
        • onclick: need to reset flag at beginning, not end (because submit could derail all the JS following)
          Tested: IE 7, 8, 9. FF 17.

        Modified: C:\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\component\selectinputdate\SelectInputDateRenderer.java
        Completed: At revision: 32907

        Modified: C:\svn\ossrepo\icefaces3\trunk\icefaces\compat\components\src\main\java\com\icesoft\faces\component\selectinputdate\SelectInputDateRenderer.java
        Completed: At revision: 32908

        Show
        yip.ng added a comment - Done. Notes: onmousedown: need to check for left click (right click does not popup) onkeydown: need to check for enter and space bar (otherwise tab also sets flag) onclick: need to reset flag at beginning, not end (because submit could derail all the JS following) Tested: IE 7, 8, 9. FF 17. Modified: C:\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\component\selectinputdate\SelectInputDateRenderer.java Completed: At revision: 32907 Modified: C:\svn\ossrepo\icefaces3\trunk\icefaces\compat\components\src\main\java\com\icesoft\faces\component\selectinputdate\SelectInputDateRenderer.java Completed: At revision: 32908
        Hide
        Carmen Cristurean added a comment -

        Fix verified with ICEfaces EE-1.8.GA-P06 Build1 in IE6/7/8/9, FF18, Chrome24.

        Show
        Carmen Cristurean added a comment - Fix verified with ICEfaces EE-1.8.GA-P06 Build1 in IE6/7/8/9, FF18, Chrome24.

          People

          • Assignee:
            yip.ng
            Reporter:
            Cruz Miraback
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: