Fixed table highlighting

Fixed live search table highlighting bug which caused random highlighted rows to appear
This commit is contained in:
law39 2020-04-21 22:30:13 +01:00
parent 60e85fe782
commit f281d46ffa

View file

@ -136,14 +136,18 @@ public class DictionaryController implements Initializable {
searchBox.textProperty().addListener((observable, oldValue, newValue) -> {
filteredList.setPredicate(dictionaryEntry -> {
// If filter text is empty, display all dictionary entries
if (newValue == null || newValue.isEmpty()) {
table.refresh(); // This fixes the table highlighting issue
if (newValue == null || newValue.isEmpty()) { // If filter text is empty, display all dictionary entries
return true;
}
// need all same case for compare.
String lowerCaseFilter = newValue.toLowerCase();
if (dictionaryEntry.getWelsh().toLowerCase().contains(lowerCaseFilter)) {
return true; // Filter matches Welsh
} else if (dictionaryEntry.getEnglish().toLowerCase().contains(lowerCaseFilter)) {
@ -151,7 +155,9 @@ public class DictionaryController implements Initializable {
}else if (dictionaryEntry.getWordType().toLowerCase().contains(lowerCaseFilter)) {
return true; // Filter matches Word Type
}
return false; // No match
});
});