cat-documents-ng 1.0.15 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -9280,6 +9280,39 @@ class DocumentListComponent {
|
|
|
9280
9280
|
*/
|
|
9281
9281
|
documentListSubscription = new Subscription();
|
|
9282
9282
|
handleSelectedDocumentInNewTab = new EventEmitter();
|
|
9283
|
+
/**
|
|
9284
|
+
* Callback function to handle opening a document in a new tab when Ctrl+Click is used.
|
|
9285
|
+
* This callback is called directly from the user gesture (preserving the gesture chain),
|
|
9286
|
+
* BEFORE any Angular change detection, so window.open() will work without popup blockers.
|
|
9287
|
+
*
|
|
9288
|
+
* IMPORTANT: Build your URL synchronously and call window.open() immediately. Do NOT:
|
|
9289
|
+
* - Use setTimeout, Promise, async/await
|
|
9290
|
+
* - Use Angular Router.navigate() (use window.open() with URL string instead)
|
|
9291
|
+
* - Trigger any operations that cause change detection before window.open()
|
|
9292
|
+
*
|
|
9293
|
+
* Best practice implementation:
|
|
9294
|
+
*
|
|
9295
|
+
* ```typescript
|
|
9296
|
+
* onOpenInNewTab = (event: { selectedDocument: any, contextId: string, documentList: any[] }) => {
|
|
9297
|
+
* // Build URL synchronously (no async operations)
|
|
9298
|
+
* const baseUrl = window.location.origin;
|
|
9299
|
+
* const params = new URLSearchParams({
|
|
9300
|
+
* selectedDocument: JSON.stringify(event.selectedDocument),
|
|
9301
|
+
* contextId: event.contextId,
|
|
9302
|
+
* documentList: JSON.stringify(event.documentList)
|
|
9303
|
+
* });
|
|
9304
|
+
* const url = `${baseUrl}/your-route?${params.toString()}`;
|
|
9305
|
+
*
|
|
9306
|
+
* // Call window.open() immediately - this preserves the user gesture chain
|
|
9307
|
+
* const newWindow = window.open(url, '_blank');
|
|
9308
|
+
* if (newWindow) {
|
|
9309
|
+
* newWindow.focus(); // Focus the new tab
|
|
9310
|
+
* }
|
|
9311
|
+
* }
|
|
9312
|
+
* ```
|
|
9313
|
+
*
|
|
9314
|
+
* @param event - The event object containing selectedDocument, contextId, and documentList
|
|
9315
|
+
*/
|
|
9283
9316
|
onOpenInNewTab;
|
|
9284
9317
|
/**
|
|
9285
9318
|
* The currently selected document.
|
|
@@ -9507,20 +9540,37 @@ class DocumentListComponent {
|
|
|
9507
9540
|
}
|
|
9508
9541
|
}
|
|
9509
9542
|
handleTableRowCtrlClick(rowData) {
|
|
9510
|
-
|
|
9511
|
-
|
|
9543
|
+
// CRITICAL: Prepare data synchronously but don't trigger any Angular operations yet
|
|
9544
|
+
// The callback MUST be called before any emit() calls to preserve user gesture chain
|
|
9545
|
+
const selectedDocument = this.documentListService.handleTableRowClick(rowData);
|
|
9512
9546
|
const event = {
|
|
9513
|
-
selectedDocument:
|
|
9547
|
+
selectedDocument: selectedDocument,
|
|
9514
9548
|
contextId: this.contextId,
|
|
9515
9549
|
documentList: this.documentList
|
|
9516
9550
|
};
|
|
9517
|
-
// Call callback
|
|
9551
|
+
// Call callback FIRST, before any Angular operations that might trigger change detection
|
|
9552
|
+
// This preserves the user gesture chain, allowing window.open() to work and focus properly
|
|
9518
9553
|
if (this.onOpenInNewTab && typeof this.onOpenInNewTab === 'function') {
|
|
9519
|
-
|
|
9520
|
-
|
|
9554
|
+
try {
|
|
9555
|
+
// Execute callback immediately while still in the user gesture chain
|
|
9556
|
+
this.onOpenInNewTab(event);
|
|
9557
|
+
// After callback completes, update component state and emit events
|
|
9558
|
+
// These operations happen after window.open() has already been called
|
|
9559
|
+
this.selectedDocument = selectedDocument;
|
|
9560
|
+
this.handleSelectedDocument.emit(this.selectedDocument);
|
|
9561
|
+
}
|
|
9562
|
+
catch (error) {
|
|
9563
|
+
console.error('Error in onOpenInNewTab callback:', error);
|
|
9564
|
+
// Fallback to event emitter if callback fails
|
|
9565
|
+
this.selectedDocument = selectedDocument;
|
|
9566
|
+
this.handleSelectedDocument.emit(this.selectedDocument);
|
|
9567
|
+
this.handleSelectedDocumentInNewTab.emit(event);
|
|
9568
|
+
}
|
|
9521
9569
|
return;
|
|
9522
9570
|
}
|
|
9523
9571
|
// Only emit if no callback provided (backward compatibility)
|
|
9572
|
+
this.selectedDocument = selectedDocument;
|
|
9573
|
+
this.handleSelectedDocument.emit(this.selectedDocument);
|
|
9524
9574
|
this.handleSelectedDocumentInNewTab.emit(event);
|
|
9525
9575
|
}
|
|
9526
9576
|
/**
|
|
@@ -10122,6 +10172,39 @@ class DocumentContainerComponent {
|
|
|
10122
10172
|
* The currently selected menu item ID for scrolling
|
|
10123
10173
|
*/
|
|
10124
10174
|
selectedMenuItemId = null;
|
|
10175
|
+
/**
|
|
10176
|
+
* Callback function to handle opening a document in a new tab when Ctrl+Click is used.
|
|
10177
|
+
* This callback is called directly from the user gesture (preserving the gesture chain),
|
|
10178
|
+
* BEFORE any Angular change detection, so window.open() will work without popup blockers.
|
|
10179
|
+
*
|
|
10180
|
+
* IMPORTANT: Build your URL synchronously and call window.open() immediately. Do NOT:
|
|
10181
|
+
* - Use setTimeout, Promise, async/await
|
|
10182
|
+
* - Use Angular Router.navigate() (use window.open() with URL string instead)
|
|
10183
|
+
* - Trigger any operations that cause change detection before window.open()
|
|
10184
|
+
*
|
|
10185
|
+
* Best practice implementation:
|
|
10186
|
+
*
|
|
10187
|
+
* ```typescript
|
|
10188
|
+
* onOpenInNewTab = (event: { selectedDocument: any, contextId: string, documentList: any[] }) => {
|
|
10189
|
+
* // Build URL synchronously (no async operations)
|
|
10190
|
+
* const baseUrl = window.location.origin;
|
|
10191
|
+
* const params = new URLSearchParams({
|
|
10192
|
+
* selectedDocument: JSON.stringify(event.selectedDocument),
|
|
10193
|
+
* contextId: event.contextId,
|
|
10194
|
+
* documentList: JSON.stringify(event.documentList)
|
|
10195
|
+
* });
|
|
10196
|
+
* const url = `${baseUrl}/your-route?${params.toString()}`;
|
|
10197
|
+
*
|
|
10198
|
+
* // Call window.open() immediately - this preserves the user gesture chain
|
|
10199
|
+
* const newWindow = window.open(url, '_blank');
|
|
10200
|
+
* if (newWindow) {
|
|
10201
|
+
* newWindow.focus(); // Focus the new tab
|
|
10202
|
+
* }
|
|
10203
|
+
* }
|
|
10204
|
+
* ```
|
|
10205
|
+
*
|
|
10206
|
+
* @param event - The event object containing selectedDocument, contextId, and documentList
|
|
10207
|
+
*/
|
|
10125
10208
|
onOpenInNewTab;
|
|
10126
10209
|
/**
|
|
10127
10210
|
* Additional navigation information for better scrolling
|