Copy paste issue

Tags: #<Tag:0x00007efc64498038>

Hi

I’m to busy to make an example, you have an issue with copy and paste, the paste seems to work but Ive had to put a delay in after changes to allow time for it to complete properly before I update my database backend with out the delay it will only save a proportion of the data, on a save button command. This is annoying and not ideal coding.

Also I have a loading screen that uses the below code to initialise
I use the afterchange with a delay to close the loading screen due to the issue above, but it doesn’t alway open the loading screen straight away, after I have run through the copy and paste sequence at least once.

contextMenu: [
                'copy',
                'cut',
                {
                    key: 'paste',
                    name: 'Paste',
                    disabled: function () {
                        return disable(this, 'Paste');
                    },
                    callback: function () {
                        view.LoadingChanged.emit(true);
                        var plugin = this.getPlugin('copyPaste');

                        this.listen();
                        plugin.paste(view.clipboardCache);

                        view.SMData = true;
                        this.render();
                    }
                },


afterChange: function (changes, source) {

// This is not great coding but fixes the bug allowing the copy paste to complete properly.

if (source === "CopyPaste.paste" && changes.length > 30) {
                    window.setTimeout(() => {
                        view.LoadingChanged.emit(false);
                    },
                        15000);
                
} else if (source === "CopyPaste.paste" && changes.length > 8) {
                    window.setTimeout(() => {
                        view.LoadingChanged.emit(false);
                    },
                        7000);

} else if (source === "CopyPaste.paste"){
                    window.setTimeout(() => {
                        view.LoadingChanged.emit(false);
                    },
                        3000);

                }

}

Hey @ben.warren

can you share a demo? I guess that it would help to know what hides under view.LoadingChanged method.

This is to big to provide an example and my work is company sensitive. view.LoadingChanged.emit(true); just allows a loading screen to be displayed through npm ngx-spinner at a different level.

i.e. Stopping any further changes until complete.

If the afterChange it not triggered at the best time you can also try one of 3 other hooks that are called for the paste action https://jsfiddle.net/d2uwqyj6/1/

Hi aleksandra_budnik

i tried these hooks before posting initially, they are delayed further and on the initial copy paste, so the loading screen i believe is in the correct place. the issue here is after the first copy paste and you do the same thing it doesn’t fire straight away.

I’ve asked @piotr.nowak to take a look at this example. Maybe he’ll be able to find some solution/approach that I do not see at this moment.

Great. So the problem isn’t really my issue with the delay on the load screen. I shouldn’t have to put a timeout in the first place, there is something odd with the copy and paste updating, becoming more apparent when copying one cell into 70+ cells. It looks like it completes but if you click on a save button it will only save a proportion of the copied cells. The longer u wait after the paste the more that get saved even though it indicates the paste has completed (I highlight the cells as they are changed via meta and css).

Hey @ben.warren, Aleksandra told me that you have a custom paste option that you’d like me to check. What’s the current progress?

Hi

I’ve tried to make a quick example, but it disproves what i’m saying. please could you leave this open and i will update again when i’ve got a little more time.

https://jsfiddle.net/knu3wbry/

or you can close this and I can open another issue when i’ve got a working issue. I will not get to this until mid next week now.

I need to fix it at some point.

I think its not happen as this is simplistic example and mine is a bit more intense, checking for changes and updating other cells, so you get multiple calls to afterChange. i.e. A net demand change would require net demand excluding vat and net margin to update … (The paste should have completed though)

We can keep the topic opened. Please send the demo over when you’ll have time.

I think its not happen as this is simplistic example and mine is a bit more intense,

Like they say - the devil is in the details. It looks like there’s something that is not obvious.

Hi Ben.

how’s going?

Hi

you might as well close this for now, there is definatly something wrong with handsontables though.

I think it has to do with beforeChange using this.setDataAtRowProp within a loop to pro rata a change through all cells.

I think afterChange is firing before this loop of changes has been finished in beforeChange. I going to try to move this loop when I get time.

OK. Feel free to open a new topic, Ben.