Skip to content

Commit e4b9204

Browse files
committed
fixed logic that would prevent saving anything when allow non-english is disabled, added immediate check on cells when the non-english feature is toggled
1 parent 5510b8b commit e4b9204

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/renderer/scripts/renderer.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ ipcRenderer.on('toggle-non-english', (event, state) => {
1111
allowNonEnglish = state;
1212
console.log(state)
1313
showToast(`Non-English characters ${state ? "enabled" : "disabled"}`);
14+
15+
// Always re-check cells whenever toggle changes
16+
const cells = document.querySelectorAll('#tableContainer td');
17+
cells.forEach(cell => validateCellContent(cell, true));
1418
});
1519

1620

@@ -674,7 +678,7 @@ function showToast(message, duration = 3000) {
674678
function validateCellContent(cell, shToast = true) {
675679
const text = cell.textContent;
676680

677-
// /[^\x00-\x7F]/
681+
// '/[^\x00-\x7F]/'
678682
if (!allowNonEnglish && /[^\x00-\x7F]/.test(text)) {
679683
cell.classList.add('invalid-char');
680684
// Optional: replace text, warn user, etc.
@@ -691,12 +695,9 @@ function validateCellContent(cell, shToast = true) {
691695

692696

693697
function hasNonEnglishCharacters() {
694-
const cells = document.querySelectorAll('#tableContainer td');
698+
const cells = document.querySelectorAll('#tableContainer td'); // selector seems to target all td elements
695699

696-
if (!Array.from(cells).some(cell => { validateCellContent(cell, false) })) {
697-
return true
698-
} else {
699-
return false
700-
}
700+
// Return true if ANY cell is invalid
701+
return Array.from(cells).some(cell => !validateCellContent(cell, false));
701702

702703
}

0 commit comments

Comments
 (0)