diff --git a/EbayListingTool/Views/SingleItemView.xaml.cs b/EbayListingTool/Views/SingleItemView.xaml.cs index 164f089..e7911e2 100644 --- a/EbayListingTool/Views/SingleItemView.xaml.cs +++ b/EbayListingTool/Views/SingleItemView.xaml.cs @@ -18,6 +18,7 @@ public partial class SingleItemView : UserControl private EbayAuthService? _auth; private EbayAspectsService? _aspectsService; private List _currentAspects = new(); + private string _lastAspectsCategoryId = ""; private ListingDraft _draft = new(); private System.Threading.CancellationTokenSource? _categoryCts; @@ -63,6 +64,7 @@ public partial class SingleItemView : UserControl // is unexpected when arriving here automatically from the Photo Analysis tab. _draft = new ListingDraft { Postcode = PostcodeBox.Text }; _currentAspects = new(); + _lastAspectsCategoryId = ""; AspectsPanel.Visibility = Visibility.Collapsed; TitleBox.Text = ""; DescriptionBox.Text = ""; @@ -639,6 +641,7 @@ public partial class SingleItemView : UserControl _draft = new ListingDraft { Postcode = PostcodeBox.Text }; _currentAspects = new(); + _lastAspectsCategoryId = ""; AspectsPanel.Visibility = Visibility.Collapsed; TitleBox.Text = ""; DescriptionBox.Text = ""; @@ -775,13 +778,24 @@ public partial class SingleItemView : UserControl try { _currentAspects = await _aspectsService.GetAspectsAsync(categoryId); - _draft.Aspects.Clear(); + + if (_lastAspectsCategoryId != categoryId) + { + _draft.Aspects.Clear(); + _lastAspectsCategoryId = categoryId; + } AspectsRequiredNote.Visibility = _currentAspects.Any(a => a.IsRequired) ? Visibility.Visible : Visibility.Collapsed; RebuildAspectFields(); } + catch + { + // Non-critical — aspects are optional for the UI flow; hide panel on failure + _currentAspects = new(); + AspectsPanel.Visibility = Visibility.Collapsed; + } finally { AspectsSpinner.Visibility = Visibility.Collapsed;