SpreadJS focus(false) aren't working properly

Posted by: ngocnguyen09910060 on 4 October 2022, 1:33 pm EST

  • Posted 4 October 2022, 1:33 pm EST

    Hi teams,

    On my application, i has 2 cell (A1, A2) are locked. So, when user operate:

    • Select A1 and Ctrl + C => select A2 and Ctrl + V.
    • Hover bottom right corner of A1 => fill handle to A2.

    InvalidOperation is fired. In this case, i’m using alert/modal to show message.

    Beside of that, i want to prevent user operate any action such as arrow key. So, i’m using:

    spread.focus(false);

    This code is working well for case “Fill handle”.

    But in case “Copy/Paste”, after close alert/modal, although SpreadJS is lost focus, user can still using arrow key on SpreadJS.

    Please check my sample source code and give me solution.

    SpreadJS_FocusFalse.zip

  • Posted 5 October 2022, 9:52 pm EST

    Hi,

    I was able to replicate the issue with both fills and copy-paste and it is because after an invalid operation spread needs to perform some internal actions. For this, you could set focus after some delay. Please refer to the following code snippet and let me know if you face any issues.

    
                spread.bind(GC.Spread.Sheets.Events.InvalidOperation, (e, args) => {
                    alert(args.message);
                    setTimeout(() => {
                        spread.focus(false);
                    }, 100)
                });

    Regards,

    Avinash

Need extra support?

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

Learn More

Forum Channels