@sap-ux/control-property-editor 0.4.6 → 0.4.7
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.
- package/CHANGELOG.md +6 -0
- package/dist/app.css.map +1 -1
- package/dist/app.js +45 -45
- package/dist/app.js.map +2 -2
- package/package.json +1 -1
- package/src/panels/outline/Tree.tsx +44 -12
- package/test/unit/panels/outline/OutlinePanel.test.tsx +60 -0
package/package.json
CHANGED
|
@@ -46,6 +46,7 @@ export const Tree = (): ReactElement => {
|
|
|
46
46
|
localStorage.getItem('theme') === 'high contrast' ? 'app-panel-hc-selected-bg' : 'app-panel-selected-bg';
|
|
47
47
|
|
|
48
48
|
const tooltipEventListeners: Record<string, (event: MouseEvent) => void> = {};
|
|
49
|
+
let currentOpenTooltipId: string | null = null;
|
|
49
50
|
|
|
50
51
|
useEffect(() => {
|
|
51
52
|
if (selection.cell === undefined && selection.group === undefined && selectedControl !== undefined) {
|
|
@@ -101,6 +102,10 @@ export const Tree = (): ReactElement => {
|
|
|
101
102
|
document.removeEventListener('click', tooltipEventListeners[tooltipId]);
|
|
102
103
|
delete tooltipEventListeners[tooltipId];
|
|
103
104
|
}
|
|
105
|
+
|
|
106
|
+
if (currentOpenTooltipId === tooltipId) {
|
|
107
|
+
currentOpenTooltipId = null;
|
|
108
|
+
}
|
|
104
109
|
};
|
|
105
110
|
|
|
106
111
|
/**
|
|
@@ -113,9 +118,14 @@ export const Tree = (): ReactElement => {
|
|
|
113
118
|
e.preventDefault();
|
|
114
119
|
const tooltip = document.getElementById(tooltipId);
|
|
115
120
|
|
|
121
|
+
if (currentOpenTooltipId && currentOpenTooltipId !== tooltipId) {
|
|
122
|
+
closeTooltip(currentOpenTooltipId);
|
|
123
|
+
}
|
|
124
|
+
|
|
116
125
|
if (tooltip) {
|
|
117
126
|
tooltip.style.visibility = 'visible';
|
|
118
127
|
tooltip.style.opacity = '1';
|
|
128
|
+
currentOpenTooltipId = tooltipId;
|
|
119
129
|
|
|
120
130
|
const handleCloseTooltip = (event: MouseEvent) => {
|
|
121
131
|
if (!tooltip.contains(event.target as Node)) {
|
|
@@ -283,24 +293,45 @@ export const Tree = (): ReactElement => {
|
|
|
283
293
|
) : (
|
|
284
294
|
<></>
|
|
285
295
|
);
|
|
296
|
+
const isExtensionPoint = item?.controlType === 'sap.ui.extensionpoint';
|
|
297
|
+
const tooltipId = `tooltip--${item?.name}`;
|
|
298
|
+
|
|
286
299
|
return item && typeof itemIndex === 'number' && itemIndex > -1 ? (
|
|
287
300
|
<div
|
|
288
301
|
aria-hidden
|
|
289
302
|
id={item.controlId}
|
|
290
303
|
className={classNames.join(' ')}
|
|
291
304
|
onClick={(): void => onSelectCell(item)}>
|
|
292
|
-
<
|
|
305
|
+
<span
|
|
293
306
|
{...props}
|
|
294
|
-
|
|
295
|
-
style={{
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
307
|
+
data-testid={isExtensionPoint ? 'tooltip-container' : ''}
|
|
308
|
+
style={{ paddingLeft: paddingValue }}
|
|
309
|
+
className={`tree-cell ${isExtensionPoint ? 'tooltip-container' : ''}`}
|
|
310
|
+
onContextMenu={(e) => isExtensionPoint && handleOpenTooltip(e, tooltipId)}>
|
|
311
|
+
{isExtensionPoint && (
|
|
312
|
+
<Icon className="right-chevron-icon extension-icon" iconName={UiIcons.DataSource} />
|
|
313
|
+
)}
|
|
314
|
+
<div
|
|
315
|
+
style={{
|
|
316
|
+
cursor: 'auto',
|
|
317
|
+
overflow: 'hidden',
|
|
318
|
+
textOverflow: 'ellipsis',
|
|
319
|
+
display: 'block'
|
|
320
|
+
}}
|
|
321
|
+
title={isExtensionPoint ? item?.name : ''}>
|
|
322
|
+
{item.name}
|
|
323
|
+
</div>
|
|
324
|
+
{isExtensionPoint && (
|
|
325
|
+
<div id={tooltipId} className="tooltip">
|
|
326
|
+
<button
|
|
327
|
+
data-testid="tooltip-dialog-button"
|
|
328
|
+
onClick={() => handleOpenFragmentDialog(item, tooltipId)}>
|
|
329
|
+
{t('ADD_FRAGMENT_AT_EXTENSION_POINT')}
|
|
330
|
+
</button>
|
|
331
|
+
</div>
|
|
332
|
+
)}
|
|
333
|
+
</span>
|
|
334
|
+
|
|
304
335
|
<div style={{ marginLeft: '10px', marginRight: '10px' }}>{indicator}</div>
|
|
305
336
|
</div>
|
|
306
337
|
) : null;
|
|
@@ -424,7 +455,8 @@ export const Tree = (): ReactElement => {
|
|
|
424
455
|
onRenderCell={onRenderCell}
|
|
425
456
|
groups={groups}
|
|
426
457
|
onSelect={onSelectHeader}
|
|
427
|
-
groupProps={groupRenderProps}
|
|
458
|
+
groupProps={groupRenderProps}
|
|
459
|
+
/>
|
|
428
460
|
</div>
|
|
429
461
|
);
|
|
430
462
|
};
|
|
@@ -372,6 +372,66 @@ describe('OutlinePanel', () => {
|
|
|
372
372
|
expect(tooltip).toHaveStyle({ visibility: 'hidden', opacity: '0' });
|
|
373
373
|
});
|
|
374
374
|
|
|
375
|
+
test('should hide tooltip if another tooltip is already open', () => {
|
|
376
|
+
const model: OutlineNode[] = [
|
|
377
|
+
{
|
|
378
|
+
name: 'one',
|
|
379
|
+
controlId: '01',
|
|
380
|
+
children: [
|
|
381
|
+
{
|
|
382
|
+
name: 'ExtensionPoint',
|
|
383
|
+
controlId: '04',
|
|
384
|
+
children: [],
|
|
385
|
+
controlType: 'sap.ui.extensionpoint',
|
|
386
|
+
editable: true,
|
|
387
|
+
visible: true
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
name: 'ExtensionPoint2',
|
|
391
|
+
controlId: '05',
|
|
392
|
+
children: [],
|
|
393
|
+
controlType: 'sap.ui.extensionpoint',
|
|
394
|
+
editable: true,
|
|
395
|
+
visible: true
|
|
396
|
+
}
|
|
397
|
+
],
|
|
398
|
+
controlType: 'name.space.one',
|
|
399
|
+
editable: true,
|
|
400
|
+
visible: true
|
|
401
|
+
}
|
|
402
|
+
];
|
|
403
|
+
const initialState: State = {
|
|
404
|
+
deviceType: DeviceType.Desktop,
|
|
405
|
+
scale: 1,
|
|
406
|
+
outline: model,
|
|
407
|
+
filterQuery: filterInitOptions,
|
|
408
|
+
scenario: scenario.AdaptationProject,
|
|
409
|
+
selectedControl: undefined,
|
|
410
|
+
changes: {
|
|
411
|
+
pending: [],
|
|
412
|
+
saved: [],
|
|
413
|
+
controls: {}
|
|
414
|
+
},
|
|
415
|
+
icons: []
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
const tooltipId = 'tooltip--ExtensionPoint';
|
|
419
|
+
const tooltipId2 = 'tooltip--ExtensionPoint2';
|
|
420
|
+
|
|
421
|
+
const { container } = render(<OutlinePanel />, { initialState });
|
|
422
|
+
const spanElements = screen.getAllByTestId('tooltip-container'); // Array of three items
|
|
423
|
+
|
|
424
|
+
// Simulate a right-click event
|
|
425
|
+
fireEvent.contextMenu(spanElements[1]);
|
|
426
|
+
fireEvent.contextMenu(spanElements[2]);
|
|
427
|
+
|
|
428
|
+
const tooltip = container.querySelector(`#${tooltipId}`);
|
|
429
|
+
const tooltip2 = container.querySelector(`#${tooltipId2}`);
|
|
430
|
+
|
|
431
|
+
expect(tooltip).toHaveStyle({ visibility: 'hidden', opacity: '0' });
|
|
432
|
+
expect(tooltip2).toHaveStyle({ visibility: 'visible', opacity: '1' });
|
|
433
|
+
});
|
|
434
|
+
|
|
375
435
|
test('do not expand to previously selected control', () => {
|
|
376
436
|
const { store, container } = render(<OutlinePanel />);
|
|
377
437
|
// clear default applied filters
|