Merge branch 'bugfix/new-recipe-selection' into 'main'

Bugfix/new recipe selection

Closes #21 and #19

See merge request cse1105/2025-2026/teams/csep-team-76!22
This commit is contained in:
Oskar Rasieński 2025-12-17 13:44:52 +01:00
commit f5eed945a2
2 changed files with 10 additions and 9 deletions

View file

@ -223,14 +223,13 @@ public class FoodpalApplicationCtrl implements LocaleAware {
*/
@FXML
private void addRecipe() {
// a default factory provides the value
Recipe newRecipe = DefaultRecipeFactory.getDefaultRecipe();
Recipe newRecipe = DefaultRecipeFactory.getDefaultRecipe(); // Create default recipe
try {
server.addRecipe(newRecipe);
refresh();
// the list focuses on the new recipe
// otherwise strange issues occur when the autofocus on edit box is called
recipeList.getFocusModel().focus(recipeList.getItems().indexOf(newRecipe));
newRecipe = server.addRecipe(newRecipe); // get the new recipe id
refresh(); // refresh view with server recipes
// Select newly created recipe
recipeList.getSelectionModel().select(recipeList.getItems().indexOf(newRecipe));
} catch (IOException | InterruptedException e) {
printError("Error occurred when adding recipe!");
}