Skip to content

Commit 574f00b

Browse files
committed
Simplify.
1 parent 5f85969 commit 574f00b

2 files changed

Lines changed: 2 additions & 47 deletions

File tree

src/platform/packages/shared/response-ops/rule_form/src/rule_details/rule_details.test.tsx

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,6 @@ jest.mock('../hooks', () => ({
2222
const { useRuleFormState, useRuleFormDispatch } = jest.requireMock('../hooks');
2323

2424
describe('RuleDetails', () => {
25-
beforeAll(() => {
26-
class ResizeObserver {
27-
observe() {}
28-
unobserve() {}
29-
disconnect() {}
30-
}
31-
32-
// this only sets the mock polyfill for this test file's env
33-
// we delete it in `afterAll` as well
34-
globalThis.ResizeObserver = ResizeObserver;
35-
});
36-
3725
beforeEach(() => {
3826
useRuleFormState.mockReturnValue({
3927
formData: {
@@ -48,12 +36,6 @@ describe('RuleDetails', () => {
4836
jest.resetAllMocks();
4937
});
5038

51-
afterAll(() => {
52-
if ('ResizeObserver' in globalThis) {
53-
delete (globalThis as any).ResizeObserver;
54-
}
55-
});
56-
5739
test('Renders correctly', () => {
5840
render(<RuleDetails />);
5941

src/platform/packages/shared/response-ops/rule_form/src/rule_details/rule_details.tsx

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
10+
import React, { useCallback, useMemo } from 'react';
1111
import {
1212
EuiFormRow,
1313
EuiFieldText,
@@ -20,8 +20,6 @@ import { RULE_NAME_INPUT_TITLE, RULE_TAG_INPUT_TITLE, RULE_TAG_PLACEHOLDER } fro
2020
import { useRuleFormState, useRuleFormDispatch } from '../hooks';
2121
import { OptionalFieldLabel } from '../optional_field_label';
2222

23-
export const RULE_DETAIL_MIN_ROW_WIDTH = 600;
24-
2523
export const RuleDetails = () => {
2624
const { formData, baseErrors } = useRuleFormState();
2725

@@ -72,13 +70,8 @@ export const RuleDetails = () => {
7270
}
7371
}, [dispatch, tags]);
7472

75-
const {
76-
ref,
77-
size: { width },
78-
} = useContainerRef();
79-
8073
return (
81-
<EuiFlexGroup ref={ref} direction={width > RULE_DETAIL_MIN_ROW_WIDTH ? 'row' : 'column'}>
74+
<EuiFlexGroup>
8275
<EuiFlexItem>
8376
<EuiFormRow
8477
data-test-subj="ruleDetails"
@@ -119,23 +112,3 @@ export const RuleDetails = () => {
119112
</EuiFlexGroup>
120113
);
121114
};
122-
123-
function useContainerRef() {
124-
const ref = useRef<HTMLDivElement | null>(null);
125-
const [size, setSize] = useState({ width: 0, height: 0 });
126-
127-
useEffect(() => {
128-
if (!ref.current) return;
129-
130-
const observer = new ResizeObserver(([entry]) => {
131-
const { width, height } = entry.contentRect;
132-
setSize({ width, height });
133-
});
134-
135-
observer.observe(ref.current);
136-
137-
return observer.disconnect;
138-
}, []);
139-
140-
return { ref, size };
141-
}

0 commit comments

Comments
 (0)