Skip to content

Commit d6c817c

Browse files
committed
use MutationObserver on <finder-file-select>
1 parent 8432e23 commit d6c817c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

client/browser/FinderFileSelect.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import React, {useEffect, useRef, useState} from 'react';
1+
import React, {RefObject, useEffect, useRef, useState} from 'react';
22
import FileSelectDialog from './FileSelectDialog';
33
import {useMutationObserver} from '../common/MutationObserver';
44

55

66
export default function FinderFileSelect(props) {
77
const shadowRoot = props.container;
8+
const hostRef = useRef(shadowRoot.host);
89
const baseUrl = props['base-url'];
910
const styleUrl = props['style-url'];
1011
const [selectedFile, setSelectedFile] = useState(props['selected-file']);
@@ -13,6 +14,12 @@ export default function FinderFileSelect(props) {
1314
const dialogRef = useRef(null);
1415
const csrfToken = getCSRFToken();
1516

17+
useMutationObserver(hostRef, (mutationList) => {
18+
for (const mutation of mutationList) {
19+
console.log(`The ${mutation.attributeName} attribute was modified.`);
20+
}
21+
}, {attributes: true});
22+
1623
useEffect(() => {
1724
// Create a styles element for the shadow DOM
1825
const link = document.createElement('link');

0 commit comments

Comments
 (0)