@@ -6,6 +6,10 @@ import { getObjectInfo } from 'lightning/uiObjectInfoApi';
6
6
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils' ;
7
7
8
8
export default class TagRelatedList extends NavigationMixin ( LightningElement ) {
9
+
10
+ hoverTimer ;
11
+ hideTimer ;
12
+
9
13
@api recordId ;
10
14
@api objectApiName ;
11
15
@api listTitle ; // Title of the list.
@@ -25,14 +29,13 @@ export default class TagRelatedList extends NavigationMixin(LightningElement) {
25
29
@api popoverFields ; //Popover additional fields (comma separated)
26
30
@api showNewRecordButton ;
27
31
@api newRecordButtonLabel ; // Button label for New Record button
28
-
32
+ @ api inactiveRecordFilter ; // Example: "Active__c = false"
29
33
30
34
@track relatedRecords ;
31
35
@track isExpanded = false ; // Accordion state
32
36
33
37
@track popoverRecordData ; // Holds the record data for the hovered row
34
38
@track showPopover = false ; // Flag to conditionally display popover
35
- hoverTimer ; // Timer for delayed popover display
36
39
@track popoverPosition = { top : 0 , left : 0 } ;
37
40
38
41
connectedCallback ( ) {
@@ -49,7 +52,6 @@ export default class TagRelatedList extends NavigationMixin(LightningElement) {
49
52
if ( data && this . dynamicUpdate === true ) {
50
53
this . getList ( ) ;
51
54
} else if ( error ) {
52
- // Handle error accordingly
53
55
}
54
56
}
55
57
@@ -186,6 +188,7 @@ export default class TagRelatedList extends NavigationMixin(LightningElement) {
186
188
}
187
189
return returnRecords ;
188
190
}
191
+
189
192
190
193
// Build the card title with record count
191
194
get cardTitle ( ) {
@@ -217,9 +220,8 @@ export default class TagRelatedList extends NavigationMixin(LightningElement) {
217
220
let style = 'vertical-align: middle; text-align: left; padding: 4px 8px; max-width: 33%' ;
218
221
// Padding for the first cell.
219
222
if ( index === 0 ) {
220
- style += 'padding-left: 5px ;' ;
223
+ style += 'padding-left: 1rem ;' ;
221
224
}
222
- // Remove extra right padding for the last cell.
223
225
if ( index === arr . length - 1 ) {
224
226
style += 'padding-right: 0px;' ;
225
227
}
@@ -230,13 +232,10 @@ export default class TagRelatedList extends NavigationMixin(LightningElement) {
230
232
} ) ;
231
233
}
232
234
233
- // Parse and combine the displayed fields and popoverFields strings into an array
234
235
get apexFieldList ( ) {
235
- // Get displayedFields (if any)
236
+ // Get fields from displayedFields and popoverFields
236
237
let displayed = this . displayedFields ? this . displayedFields . replace ( / \s / g, '' ) . split ( ',' ) : [ ] ;
237
- // Get popoverFields (if any)
238
238
let popover = this . popoverFields ? this . popoverFields . replace ( / \s / g, '' ) . split ( ',' ) : [ ] ;
239
- // Combine them and remove duplicates
240
239
let combined = Array . from ( new Set ( [ ...displayed , ...popover ] ) ) ;
241
240
242
241
// extract the field name and add it to the list if not already present.
@@ -275,25 +274,29 @@ export default class TagRelatedList extends NavigationMixin(LightningElement) {
275
274
} , obj || { } ) ;
276
275
}
277
276
278
- // Event handler for mouse enter on a record row
279
277
handleMouseEnter ( event ) {
280
278
const recordId = event . currentTarget . dataset . recordId ;
281
279
const rect = event . currentTarget . getBoundingClientRect ( ) ;
282
- // Adjusting the position slightly (you can fine‑tune the offsets)
283
280
this . popoverPosition = {
284
- top : rect . top + 10 ,
285
- left : rect . left + 10
281
+ top : rect . top + 2 ,
282
+ left : rect . left + 2
286
283
} ;
287
284
this . hoverTimer = window . setTimeout ( ( ) => {
288
285
this . popoverRecordData = this . relatedRecords . find ( rec => rec . Id === recordId ) ;
289
286
this . showPopover = true ;
290
- } , 1500 ) ;
287
+ } , 1000 ) ;
291
288
}
292
289
293
- // Event handler for mouse leave from a record row (or popover)
294
290
handleMouseLeave ( ) {
295
291
window . clearTimeout ( this . hoverTimer ) ;
296
- this . showPopover = false ;
292
+ this . hideTimer = window . setTimeout ( ( ) => {
293
+ this . showPopover = false ;
294
+ } , 200 ) ; // Delay closing popover to allow mouse movement
295
+ }
296
+
297
+ handlePopoverEnter ( ) {
298
+ // Prevent hiding when entering the popover
299
+ window . clearTimeout ( this . hideTimer ) ;
297
300
}
298
301
299
302
// Getter to combine displayedFields with additional popoverFields
@@ -303,7 +306,6 @@ export default class TagRelatedList extends NavigationMixin(LightningElement) {
303
306
304
307
// Getter to prepare an array of objects with localized field labels and values from the hovered record
305
308
get popoverFieldValues ( ) {
306
- // Ensure we have the record data and the object metadata
307
309
if ( ! this . popoverRecordData || ! this . objectInfo . data ) {
308
310
return [ ] ;
309
311
}
@@ -332,7 +334,17 @@ export default class TagRelatedList extends NavigationMixin(LightningElement) {
332
334
top: ${ relativeTop + 20 } px;
333
335
left: ${ relativeLeft } px;
334
336
z-index: 1000;
335
- transform: translate(-50%, 0);` ;
337
+ transform: translate(0, 0);` ;
338
+ }
339
+ return '' ;
340
+ }
341
+
342
+ get popoverTitle ( ) {
343
+ if ( this . popoverRecordData && this . displayedFieldList && this . displayedFieldList . length > 0 && this . objectInfo . data ) {
344
+ // Get the first field's API name from the displayedFields array
345
+ let firstFieldApiName = this . displayedFieldList [ 0 ] ;
346
+ let fieldValue = this . resolve ( firstFieldApiName , this . popoverRecordData ) ;
347
+ return `${ fieldValue } ` ;
336
348
}
337
349
return '' ;
338
350
}
0 commit comments