|
1 |
| -import React, { useEffect } from 'react'; |
| 1 | +import React, { useState } from 'react'; |
2 | 2 | import { JSONTree } from 'react-json-tree'; // React JSON Viewer Component;
|
3 | 3 | import { setCurrentTabInApp, toggleAxTree } from '../../slices/mainSlice';
|
4 | 4 | import { useDispatch } from 'react-redux';
|
| 5 | +import { display, style } from '@mui/system'; |
5 | 6 |
|
6 | 7 | const theme = {
|
7 | 8 | scheme: 'monokai',
|
@@ -33,20 +34,54 @@ const AxTree = (props) => {
|
33 | 34 | } = props;
|
34 | 35 |
|
35 | 36 | const dispatch = useDispatch();
|
| 37 | + const [hideButton, setHideButton] = useState(true); |
| 38 | + const [showTree, setShowTree] = useState(false); |
| 39 | + const [selectedValue, setSelectedValue] = useState('disable') |
36 | 40 |
|
37 |
| - let AccessibilityHasBeenDisabled = true; |
38 |
| - const enableAxTreeButton = () => { |
| 41 | + const enableAxTreeButton = () => { |
39 | 42 | dispatch(toggleAxTree('toggleAxRecord'));
|
40 | 43 | dispatch(setCurrentTabInApp('AxTree'));
|
41 |
| - AccessibilityHasBeenDisabled = false; |
| 44 | + setSelectedValue('enable') |
| 45 | + setHideButton(false); |
| 46 | + setShowTree(true); |
42 | 47 | }
|
43 | 48 |
|
| 49 | + const disableAxTree = () => { |
| 50 | + setSelectedValue('disable'); |
| 51 | + setShowTree(false); |
| 52 | + } |
| 53 | + |
| 54 | + // useEffect(() => { |
| 55 | + // // dispatch sent at initial page load allowing changing "immer's" draft.currentTabInApp to 'tree' to facilitate render. |
| 56 | + // }, []); |
| 57 | + |
44 | 58 |
|
45 | 59 | return (
|
46 | 60 | <div>
|
47 |
| - { |
48 |
| - AccessibilityHasBeenDisabled ? <button onClick={enableAxTreeButton}>Click Here to Enable Accessibility</button> : |
49 |
| - <JSONTree |
| 61 | + <p>A Note to Developers: Reactime is using the Chrome Debugging API in order to grab the Accessibility Tree. Enabling this option will allow you to record Accessibility Tree snapshots, but will result in the Chrome browser notifying you that the Chrome Debugger has started.</p> |
| 62 | + {/* {<button onClick={enableAxTreeButton}>Click Here to Enable Accessibility</button>} */} |
| 63 | + <div> |
| 64 | + {<input |
| 65 | + type='radio' |
| 66 | + value='enable' |
| 67 | + checked={selectedValue === 'enable'} |
| 68 | + onChange={() => { |
| 69 | + enableAxTreeButton(); |
| 70 | + }} |
| 71 | + />} |
| 72 | + <label htmlFor='enable'>Enable</label> |
| 73 | + {<input |
| 74 | + type='radio' |
| 75 | + value='disable' |
| 76 | + checked={selectedValue === 'disable'} |
| 77 | + onChange={() => { |
| 78 | + disableAxTree(); |
| 79 | + }} |
| 80 | + />} |
| 81 | + <label htmlFor='disable'>Disable</label> |
| 82 | + </div> |
| 83 | + |
| 84 | + {showTree && <JSONTree |
50 | 85 | data={axSnapshots[currLocation.index]}
|
51 | 86 | // shouldExpandNodeInitially={() => false}
|
52 | 87 | theme={theme}
|
|
0 commit comments