FlexSheet - First character is not entered in custom editor

Posted by: holly.anderson on 7 November 2017, 6:54 am EST

    • Post Options:
    • Link

    Posted 7 November 2017, 6:54 am EST

    Hello,

    I’m having a problem with build 5.20172.359. I have custom editors in certain columns in a FlexSheet, which I configure via the formatItem event. When a user types on such a cell in quick-edit mode, I expect that the character they typed will appear in the custom editor. This is what was happening in build 5.20172.334. With the new build, the first character entered by the user does not register, and they have to type it again in order for it to appear in the cell.

    Please see the attached sample and follow these steps to replicate:

    1. Single-click in a cell in column D.
    2. Type a number.

    Results: The entered number does not appear in the cell. Instead, the cell is empty.

    Any advice on how to get around this issue?

    Thanks,

    Holly

    FlexSheetDemo_CustomEditors2.zip

  • Posted 7 November 2017, 5:18 pm EST

    Hi Holly,

    You need to set handle keydown event and get the key and set to the control value. Please refer to the following code snippet:

    sheet.hostElement.addEventListener("keydown",function(e){
                       key=e.key;
                })
                // Format Item
                sheet.formatItem.addHandler(function (s, e) {
                    var editRange = sheet.editRange,
                        column = e.panel.columns[e.col];
    
                    if (editRange && editRange.row == e.row && editRange.col == e.col) {
                        if (column.binding === "units") {
    
                            if (e.cell.firstChild) {
                                $(e.cell.firstChild).hide();
                            }
    
                            // Add custom editor
                            var editRoot = document.createElement('div');
                            var input = $("<input />");
                            console.log(key)
                            input.val(key);
                            input.width("100%").css("border", "none").css("text-align", "right");
                            $(editRoot).append(input);                        
                            e.cell.appendChild(editRoot);
                            input.focus();
                            
    
                            // CellEditEnding that updates cell with input
                            var editEndingEH = function (s, args) {
                                sheet.cellEditEnding.removeHandler(editEndingEH);
                                if (!args.cancel) {
                                    args.cancel = true;
                                    sheet.setCellData(args.row, args.col, input.val());
                                }
                            };
    
                            // Subscribe the handler to the cellEditEnding event
                            sheet.cellEditEnding.addHandler(editEndingEH);
                        }
                    }
                });
    

    ~Manish

  • Posted 7 November 2017, 11:59 pm EST

    Hi Manish,

    This solution leads to undesired behavior when non-printable keys are pressed. For example:

    1. Single-click in the first cell in column D.
    2. Use the down arrow to go the next row.
    3. Single-click on the second cell in column D (now highlighted).

    Results: “ArrowDown” appears in the second cell in column D.

    Was this behavior intentionally changed in the new build? If so, what was the reasoning behind the change?

    Holly

  • Posted 8 November 2017, 5:17 pm EST

    Hi Holly,

    This is not the behavior intentionally changed. This is because of workaround provided to you.

    Please refer to the attached sample for the same.

    ~Manish

    FlexSheetDemo_CustomEditors_updated.zip

  • Posted 9 November 2017, 12:58 am EST

    I’m having another issue with custom editors in build 5.20172.359. If I double-click quickly in a cell that contains a custom editor, the custom editor does not retain focus (despite the line input.focus();). So when I type, the characters are not registered in the custom editor.

    You can see this issue in the sample you provided. Please note that you have to double-click quickly in a cell in order to see this behavior. If you double-click at a slower pace, the issue does not occur. Again, this issue was not occurring in build 5.20172.334.

    Holly

  • Posted 9 November 2017, 1:21 am EST

    Hi Manish,

    The new sample fails in the following case:

    1. Single-click in the first cell in column C.
    2. Press Ctrl+c to copy the contents of the cell.
    3. Single-click on the first cell in column D.
    4. Press Ctrl+v to paste the copied content.
    5. Double-click on the second cell in column D.

    Results: “v” appears in the second cell in column D.

    I know we can check if e.ctrlKey is true, but then we’d also have to check e.altKey and other similar properties. With a workaround of this type, I’d be worried that there is some special case that it wouldn’t work for.

    Another problem with this workaround is that if I single-click on a cell and type “abc”, the input appears in the cell as “bca”.

    When I asked if the behavior was intentionally changed, I was referring to the fact that in previous builds, the first character was registered in custom editors without any workarounds. If such a change was unintentional, would it be possible to log this as a bug? It’s unfortunate that this functionality was lost and now we have to go to extra lengths to get it to work as expected.

    Holly

  • Posted 10 November 2017, 12:30 am EST

    Hi,

    We are investigating on this.

    ~Manish

  • Posted 12 November 2017, 8:26 pm EST

    Hi Holly,

    We are able to find out the solution for all above mentioned issues. We need to handle beginningEdit event for the same and capture the key value and assigned to the editor. Please refer to the updated sample probably the final solution.

    ~ManishFlexSheetDemo_CustomEditors_beginEdt_updated.zip

  • Posted 12 November 2017, 11:51 pm EST

    Hi Manish,

    This solution doesn’t fix the following issues mentioned in my previous replies:

    1. IE: If I single-click on a cell and type “abc”, the input appears in the cell as “bca”.
    2. IE/Chrome: I still have the problem where if I double-click very quickly in a cell that contains a custom editor, the custom editor does not retain focus. I realize I can probably get around this by adjusting the timeout, but I really don’t think I should have to rely on two different timeouts working together and being executed in the correct time frame in relation to each other.

    I still think this should be logged as a bug because custom editors and quick-edit mode were working perfectly fine together in build 5.20172.334 without any workarounds. At this point, I’m seriously considering reverting back to that build.

    Holly

  • Posted 13 November 2017, 9:04 pm EST

    Hi Holly,

    We have reported this as bug with id 296961. We will let you know as we get any update on this.

    However, we are not able to replicate the issue 2 in IE with the sample provided in previous reply.

    ~Manish

  • Posted 14 November 2017, 2:41 am EST

    Hi Manish,

    Thank you for logging this as a bug. I’m hoping it can be addressed soon because this is a big issue for me.

    As for not being able to replicate the second issue, it only happens if you double-click very quickly in the cell. For example, if the clicks are within a millisecond of each other, you should see the problem. I admit that it’s unlikely for someone to click that fast, but it is possible and it further illustrates why I don’t want to have to rely on a workaround with multiple timeouts to get around this problem.

    Holly

  • Posted 14 November 2017, 5:45 pm EST

    Hi Holly,

    Thanks for clarifying the scenario.

    ~Manish

  • Posted 26 November 2017, 11:35 pm EST

    Is there any update on this issue? My FlexSheet implementation relies heavily on custom editors, and I can’t upgrade until this issue is fixed or a reliable workaround is provided.

  • Posted 27 November 2017, 6:19 pm EST

    Hi Holly,

    This issue is fixed under an internal build. I would update here when that version is available publicly.

    Thank you for reporting this.

    ~nilay

  • Posted 27 November 2017, 11:35 pm EST

    Hi Nilay,

    Thanks for the update. Can you confirm if this is fixed in pre-release version 5.20173.381_2017.11.27? I’d like to test it out while waiting for the official release.

    Thanks,

    Holly

  • Posted 30 November 2017, 7:04 am EST

    Also, do you have an idea of when the build that contains this fix will be officially released?

  • Posted 1 December 2017, 4:14 am EST

    I tested this in pre-release build 5.20173.382 and I’m still experiencing one of the problems I reported earlier.

    If I double-click very quickly in a cell that contains a custom editor, the custom editor does not retain focus. This also occurs if I type a character immediately (i.e. within milliseconds) after navigating to a cell with a custom editor via the arrow keys. When I type the character, it does not appear in the cell and the custom editor loses focus.

  • Posted 3 December 2017, 6:02 pm EST

    Hi Holly,

    The fix is included in 384 build. Please verify your issue.

    ~nilay

  • Posted 4 December 2017, 12:13 am EST

    I’m still experiencing the problem. I used the sample from my original post with the latest pre-release version (5.20173.385). Some of the issues I reported have been resolved. For example, if I single-click in a cell with the custom editor, the typed characters are appearing in the cell. Also, if I double click in a cell at a normal speed, then the custom editor works fine. However, if I double click very quickly in a cell with a custom editor, the editor does not retain focus and I cannot type in the cell. Please see attached screen recording, which illustrates the issue.

    CustomEditors.zip

  • Posted 4 December 2017, 10:39 pm EST

    Hi holly,

    We are sorry, we are unable to replicate the issue at our end. Please refer to the attached screencast for the same:

    https://www.screencast.com/t/0OyQzQ9nPHg

    However, we have forwarded your video to the concerned team for investigation.

    ~Manish

  • Posted 5 December 2017, 12:13 am EST

    Hi Manish,

    I think I’ve found another way to replicate the issue. When I use the startEditing method to enter full-edit mode on a cell with a custom editor, the custom editor does not retain focus. Please see the attached sample which illustrates the issue. If you click the ‘Edit Col C’ button, the first cell in column C is selected, and any characters that you type will appear in the cell. Note that column C does not have custom editors. If you click the ‘Edit Col D’ button, the first cell in column D is selected, and the custom editor loses focus. So any characters you type do not appear in the cell.

    Interestingly, if you click the ‘Edit Col D’ button first, then the custom editor retains focus as expected. I’m not sure if this is the same issue as I initially reported, but the results seem similar.

    Holly

    FlexSheetDemo_CustomEditors3.zip

  • Posted 5 December 2017, 9:27 pm EST

    Hi Holly,

    Thanks for reporting with new scenario. We have forwarded this to the concerned team for further investigation.

    ~Manish

  • Posted 13 December 2017, 12:48 am EST

    This issue seems to be fixed in the latest pre-release build. Can someone please confirm?

  • Posted 13 December 2017, 1:12 am EST

    Hi Holly,

    The issue has been fixed and can be found fixed in the build 5.20173.390.

    ~Manish

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels