Skip to content

Commit e01d2ae

Browse files
authored
Revert "Fix DistributionBar component left overflow edge case (elastic#238300)" (elastic#244520)
## Summary Reverts the fix for: - elastic/security-team#10048 as it introduced regression <img width="1505" height="765" alt="Screenshot 2025-11-27 at 13 10 27" src="https://github.com/user-attachments/assets/7d43ee66-6abe-4c72-bc49-4bd139021f22" /> ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels.
1 parent 4f3f483 commit e01d2ae

File tree

3 files changed

+31
-323
lines changed

3 files changed

+31
-323
lines changed

x-pack/solutions/security/packages/distribution-bar/src/distribution_bar.stories.tsx

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -46,68 +46,6 @@ const mockStatsAlerts = [
4646
},
4747
];
4848

49-
// Edge case: Flip tooltip when the LEFTMOST segment (green/teal) is very small
50-
const mockStatsEdgeCase = [
51-
{
52-
key: 'low',
53-
count: 220,
54-
color: 'green',
55-
label: 'Low',
56-
},
57-
{
58-
key: 'medium',
59-
count: 2000,
60-
color: 'gold',
61-
label: 'Medium',
62-
},
63-
{
64-
key: 'high',
65-
count: 1500,
66-
color: 'orange',
67-
label: 'High',
68-
},
69-
{
70-
key: 'critical',
71-
count: 1000,
72-
color: 'red',
73-
label: 'Critical',
74-
},
75-
];
76-
77-
// Edge case: Multiple small segments at the beginning (leftmost)
78-
const mockStatsMultipleSmall = [
79-
{
80-
key: 'low1',
81-
count: 3,
82-
color: 'green',
83-
label: 'Low 1',
84-
},
85-
{
86-
key: 'low2',
87-
count: 2,
88-
color: 'green',
89-
label: 'Low 2',
90-
},
91-
{
92-
key: 'medium',
93-
count: 3000,
94-
color: 'gold',
95-
label: 'Medium',
96-
},
97-
{
98-
key: 'high',
99-
count: 2000,
100-
color: 'orange',
101-
label: 'High',
102-
},
103-
{
104-
key: 'critical',
105-
count: 1000,
106-
color: 'red',
107-
label: 'Critical',
108-
},
109-
];
110-
11149
export default {
11250
title: 'DistributionBar',
11351
description: 'Distribution Bar',
@@ -148,24 +86,3 @@ export const DistributionBar = () => {
14886
</React.Fragment>,
14987
];
15088
};
151-
152-
export const EdgeCaseSmallSegments = () => {
153-
return [
154-
<React.Fragment key={'edge-case-tooltip-overflow'}>
155-
<EuiTitle size={'xs'}>
156-
<h4>{'Edge Case: Tooltip Change Direction'}</h4>
157-
</EuiTitle>
158-
<EuiSpacer size={'s'} />
159-
<DistributionBarComponent stats={mockStatsEdgeCase} />
160-
<EuiSpacer size={'m'} />
161-
</React.Fragment>,
162-
<React.Fragment key={'edge-case-multiple-small'}>
163-
<EuiTitle size={'xs'}>
164-
<h4>{'Edge Case: Multiple Small Segments at Beginning'}</h4>
165-
</EuiTitle>
166-
<EuiSpacer size={'s'} />
167-
<DistributionBarComponent stats={mockStatsMultipleSmall} />
168-
<EuiSpacer size={'m'} />
169-
</React.Fragment>,
170-
];
171-
};

x-pack/solutions/security/packages/distribution-bar/src/distribution_bar.test.tsx

Lines changed: 0 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -142,145 +142,4 @@ describe('DistributionBar', () => {
142142
});
143143

144144
// todo: test tooltip visibility logic
145-
146-
describe('tooltip overflow edge cases', () => {
147-
it('should add flipped tooltip attribute for small segments', () => {
148-
// Mock getBoundingClientRect to simulate small segment that would overflow
149-
const mockGetBoundingClientRect = jest.fn();
150-
151-
const containerRect = {
152-
left: 0,
153-
right: 500,
154-
width: 500,
155-
top: 0,
156-
bottom: 0,
157-
x: 0,
158-
y: 0,
159-
toJSON: () => ({}),
160-
};
161-
162-
const smallPartRect = {
163-
left: 0,
164-
right: 50,
165-
width: 50,
166-
top: 0,
167-
bottom: 0,
168-
x: 0,
169-
y: 0,
170-
toJSON: () => ({}),
171-
};
172-
173-
const tooltipContentRect = {
174-
left: 0,
175-
right: 120,
176-
width: 120,
177-
top: 0,
178-
bottom: 0,
179-
x: 0,
180-
y: 0,
181-
toJSON: () => ({}),
182-
};
183-
184-
const largePartRect = {
185-
left: 250,
186-
right: 500,
187-
width: 250,
188-
top: 0,
189-
bottom: 0,
190-
x: 0,
191-
y: 0,
192-
toJSON: () => ({}),
193-
};
194-
195-
Element.prototype.getBoundingClientRect = mockGetBoundingClientRect
196-
.mockReturnValueOnce(containerRect)
197-
.mockReturnValueOnce(smallPartRect)
198-
.mockReturnValueOnce(tooltipContentRect)
199-
.mockReturnValueOnce(largePartRect)
200-
.mockReturnValueOnce(tooltipContentRect);
201-
202-
const stats = [
203-
{
204-
key: 'small',
205-
count: 1,
206-
color: 'green',
207-
label: 'Small',
208-
},
209-
{
210-
key: 'large',
211-
count: 1000,
212-
color: 'red',
213-
label: 'Large',
214-
},
215-
];
216-
217-
const { container } = render(<DistributionBar stats={stats} data-test-subj={testSubj} />);
218-
expect(container).toBeInTheDocument();
219-
220-
const parts = container.querySelectorAll(`[data-test-subj="${testSubj}__part"]`);
221-
expect(parts.length).toEqual(stats.length);
222-
223-
expect(parts[0].getAttribute('data-tooltip-flipped')).toBe('true');
224-
225-
expect(parts[1].getAttribute('data-tooltip-flipped')).toBe('false');
226-
227-
mockGetBoundingClientRect.mockRestore();
228-
});
229-
230-
it('should not flip tooltip when there is enough space', () => {
231-
const mockGetBoundingClientRect = jest.fn();
232-
233-
const containerRect = {
234-
left: 0,
235-
right: 500,
236-
width: 500,
237-
top: 0,
238-
bottom: 0,
239-
x: 0,
240-
y: 0,
241-
toJSON: () => ({}),
242-
};
243-
const partRect = {
244-
left: 200,
245-
right: 500,
246-
width: 300,
247-
top: 0,
248-
bottom: 0,
249-
x: 200,
250-
y: 0,
251-
toJSON: () => ({}),
252-
};
253-
const tooltipRect = {
254-
left: 0,
255-
right: 120,
256-
width: 120,
257-
top: 0,
258-
bottom: 0,
259-
x: 0,
260-
y: 0,
261-
toJSON: () => ({}),
262-
};
263-
264-
Element.prototype.getBoundingClientRect = mockGetBoundingClientRect
265-
.mockReturnValueOnce(containerRect)
266-
.mockReturnValueOnce(partRect)
267-
.mockReturnValueOnce(tooltipRect);
268-
269-
const stats = [
270-
{
271-
key: 'medium',
272-
count: 500,
273-
color: 'yellow',
274-
label: 'Medium',
275-
},
276-
];
277-
278-
const { container } = render(<DistributionBar stats={stats} data-test-subj={testSubj} />);
279-
280-
const parts = container.querySelectorAll(`[data-test-subj="${testSubj}__part"]`);
281-
expect(parts[0].getAttribute('data-tooltip-flipped')).toBe('false');
282-
283-
mockGetBoundingClientRect.mockRestore();
284-
});
285-
});
286145
});

0 commit comments

Comments
 (0)