Issue created by the new function to copy TM to the sidebar
psmits1567 opened this issue · 6 comments
With the new functionality copy TM to the sidebar (which I find useless, as they are already present below the editor) I get the following errors
Uncaught TypeError: Cannot read properties of null (reading 'find')
at copyTranslationMemoryToSidebarTab (translation-suggestions.js?ver=1683883952:59:48)
at Object. (translation-suggestions.js?ver=1683883952:35:5)
at c (load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,thickbox,wp-polyfill-inert,regenerator-runtime,wp-polyfill,jquery-ui-core,jquery-ui-tooltip&ver=6.3-alpha-55746:2:28447)
at Object.fireWith [as resolveWith] (load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,thickbox,wp-polyfill-inert,regenerator-runtime,wp-polyfill,jquery-ui-core,jquery-ui-tooltip&ver=6.3-alpha-55746:2:29192)
at l (load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,thickbox,wp-polyfill-inert,regenerator-runtime,wp-polyfill,jquery-ui-core,jquery-ui-tooltip&ver=6.3-alpha-55746:2:80176)
at XMLHttpRequest. (load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,thickbox,wp-polyfill-inert,regenerator-runtime,wp-polyfill,jquery-ui-core,jquery-ui-tooltip&ver=6.3-alpha-55746:2:82630)
Possible solutions:
- Fix this error
- Make this function optional
- remove this function as it has no us
Additional comment to this issue, it is not tested properly !!
Without any plugins installed, if you go to the last line in the untranslated list, then add a translation, the error is also produced!!
How to reproduce:
1, open a project
2. open the list of untranslated originals
3. go to the last line in the list
4. copy the original into the editor
5. save the editor
6. Look in the developer console
7. error shown
translation-suggestions.js?ver=1683883952:59 Uncaught TypeError: Cannot read properties of null (reading 'find')
at copyTranslationMemoryToSidebarTab (translation-suggestions.js?ver=1683883952:59:48)
at Object. (translation-suggestions.js?ver=1683883952:35:5)
at c (load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,thickbox,wp-polyfill-inert,regenerator-runtime,wp-polyfill,jquery-ui-core,jquery-ui-tooltip&ver=6.3-alpha-55746:2:28447)
at Object.fireWith [as resolveWith] (load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,thickbox,wp-polyfill-inert,regenerator-runtime,wp-polyfill,jquery-ui-core,jquery-ui-tooltip&ver=6.3-alpha-55746:2:29192)
at l (load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,thickbox,wp-polyfill-inert,regenerator-runtime,wp-polyfill,jquery-ui-core,jquery-ui-tooltip&ver=6.3-alpha-55746:2:80176)
at XMLHttpRequest. (load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,thickbox,wp-polyfill-inert,regenerator-runtime,wp-polyfill,jquery-ui-core,jquery-ui-tooltip&ver=6.3-alpha-55746:2:82630)
This happens because the editor is closed, so the function cannot read ".meta.translation-memory" as it is no longer available
There should be a check first if this element is present, if it is not then return
var divSidebarWithTM = $gp.editor.current.find( '.meta.translation-memory' ).first();
var divId = divSidebarWithTM.attr( 'data-row-id' );
var TMcontainer = $gp.editor.current.find( '.suggestions__translation-memory' );
if ( !TMcontainer.length ) {
return;
}
Additional findings, why it this line in the meta tab clickable : Suggestions from Translation Memory
If you click on it, you immediately get the error described!
This is not possible in the line below the editor!
Thank you for outline these steps @psmits1567 , we will take a look.
@trymebytes thanks would be nice if it could be fixed quickly. Also my question is, why are the suggestions still shown below the editor if this functionality is going to be moved to a Meta tab? Now it takes time to put them below the editor, then copy them to Meta tab. If this functionality stays, then it is no longer necessary to show them below the editor, they can be put into the editor directly.
Hi @psmits1567
I can't reproduce this error following your steps, so I think this problem is solved. Can I close this issue? Thank you
@amieiro hi, yes it does not happen anymore so can be closed