You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During submission creation, when selecting Creative Commons license and clicking through its options, the "Saving..." indicator would appear infinitely. After reloading the page, the Creative Commons checkbox would be checked but the license value was not stored in metadata.
5
+
6
+
## Fix Applied
7
+
The issue was resolved by implementing:
8
+
1.**Debounced API calls** (300ms delay) to prevent excessive license link requests
9
+
2.**Observable caching** using `shareReplay(1)` to avoid redundant HTTP calls
10
+
3.**Improved state change detection** to prevent unnecessary JSON patch operations
11
+
4.**Proper subscription management** to prevent memory leaks
12
+
13
+
## Testing Steps
14
+
15
+
### Before Testing
16
+
1. Build and start the DSpace Angular application:
17
+
```bash
18
+
cd c:\dspace-angular-clarin
19
+
npm start
20
+
```
21
+
22
+
### Test Scenario 1: Rapid Option Selection
23
+
1. Navigate to submission creation page
24
+
2. Choose Creative Commons from the license dropdown
25
+
3.**Rapidly click** through different license options (e.g., BY, BY-SA, BY-NC, etc.)
26
+
4.**Expected Result**:
27
+
- No infinite "Saving..." indicator
28
+
- Options respond immediately to clicks
29
+
- License link appears/updates smoothly
30
+
31
+
### Test Scenario 2: License Acceptance and Persistence
32
+
1. Select a Creative Commons license type
33
+
2. Choose your preferred options (commercial use, derivatives, etc.)
34
+
3.**Check the acceptance checkbox** for the generated license link
35
+
4. Save the submission (Save for Later)
36
+
5.**Reload the page**
37
+
6.**Expected Result**:
38
+
- Creative Commons section shows as selected
39
+
- License URI is properly stored in metadata
40
+
- Previous options are preserved
41
+
42
+
### Test Scenario 3: Performance Verification
43
+
1. Open browser developer tools (F12)
44
+
2. Go to Network tab
45
+
3. Navigate to Creative Commons section
46
+
4. Rapidly change license options
47
+
5.**Expected Result**:
48
+
- Fewer HTTP requests to license URL endpoints
49
+
- No duplicate or overlapping requests
50
+
- Requests are debounced (not immediate)
51
+
52
+
### Test Scenario 4: Submission Completion
53
+
1. Complete the Creative Commons license selection
54
+
2. Fill out other required submission sections
55
+
3. Submit/deposit the item
56
+
4.**Expected Result**:
57
+
- Submission completes successfully
58
+
- Creative Commons license metadata is included in final item
59
+
60
+
## Expected Behavior Changes
61
+
62
+
### Before Fix
63
+
- ❌ Infinite "Saving..." indicator
64
+
- ❌ Multiple simultaneous API calls
65
+
- ❌ License URI not stored in metadata
66
+
- ❌ Poor performance with rapid clicks
67
+
68
+
### After Fix
69
+
- ✅ Smooth interaction with no infinite saving
70
+
- ✅ Debounced API calls (max 1 per 300ms)
71
+
- ✅ License URI properly persisted
72
+
- ✅ Responsive performance even with rapid clicks
73
+
74
+
## Verification Points
75
+
76
+
1.**No Console Errors**: Check browser console for any JavaScript errors
77
+
2.**Network Efficiency**: Reduced number of HTTP requests in Network tab
78
+
3.**Data Persistence**: License data survives page reloads
If any issues are discovered, the changes can be easily reverted by restoring the original `submission-section-cc-licenses.component.ts` file from git history.
83
+
84
+
## Technical Details
85
+
The fix is implemented entirely within the Angular component layer and does not affect:
The Creative Commons license section in the submission form was experiencing infinite saving loops when users clicked on license options. The "Saving..." indicator would appear indefinitely, preventing users from continuing with their submission.
5
+
6
+
## Root Cause Analysis
7
+
The issue was caused by:
8
+
9
+
1.**Lack of debouncing**: Rapid clicks on CC license options triggered multiple immediate HTTP requests to fetch license links
10
+
2.**Inefficient observable handling**: The `ccLicenseLink$` observable was being recreated on every change without proper caching
11
+
3.**Overly sensitive state subscriptions**: The section state subscription was triggering unnecessary JSON patch operations on every minor change
12
+
13
+
## Solution Implemented
14
+
15
+
### 1. Added Debouncing Mechanism
16
+
- Introduced `ccLicenseLinkTrigger$` Subject to control when license link updates are triggered
17
+
- Added 300ms debouncing to prevent rapid successive API calls
18
+
- Used `switchMap` to cancel previous requests when new ones are triggered
19
+
20
+
### 2. Improved Observable Caching
21
+
- Used `shareReplay(1)` to cache the latest license link result
22
+
- Added `distinctUntilChanged` to prevent duplicate emissions
23
+
- Proper initialization with `startWith(undefined)`
24
+
25
+
### 3. Enhanced State Change Detection
26
+
- Improved the `distinctUntilChanged` operator to properly compare Creative Commons license data
27
+
- Added more precise filtering to prevent unnecessary patch operations
28
+
- Only trigger URI operations when acceptance state actually changes
0 commit comments