diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx index f0479d8eac..77d4f0c5fa 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx @@ -3,59 +3,59 @@ import { initialState, reducer } from '../../reducers/assembly-items' import './styles/assembly-items.css' export const AssemblyItems = ({ registerEvent }) => { - const [assemblyItems, dispatch] = useReducer(reducer, initialState) - const [selectedItem, setSelectedItem] = useState(0) - const refs = useRef({}) - const asmItemsRef = useRef(null) - - useEffect(()=>{ - registerEvent && registerEvent('codeManagerChanged', (code, address, index) => { - dispatch({ type: 'FETCH_OPCODES_SUCCESS', payload: { code, address, index } }) - }) - }, []) - - useEffect(() => { - if (selectedItem !== assemblyItems.index) { - indexChanged(assemblyItems.index) - } - }, [assemblyItems.index]) - - const indexChanged = (index: number) => { - if (index < 0) return - let currentItem = refs.current[selectedItem] ? refs.current[selectedItem] : null - - if (currentItem) { - currentItem.removeAttribute('selected') - currentItem.removeAttribute('style') - if (currentItem.firstChild) { - currentItem.firstChild.removeAttribute('style') - } - const codeView = asmItemsRef.current - - currentItem = codeView.children[index] - currentItem.style.setProperty('border-color', 'var(--primary)') - currentItem.style.setProperty('border-style', 'solid') - currentItem.setAttribute('selected', 'selected') - codeView.scrollTop = currentItem.offsetTop - parseInt(codeView.offsetTop) - setSelectedItem(index) - } + const [assemblyItems, dispatch] = useReducer(reducer, initialState) + const [selectedItem, setSelectedItem] = useState(0) + const refs = useRef({}) + const asmItemsRef = useRef(null) + + useEffect(() => { + registerEvent && registerEvent('codeManagerChanged', (code, address, index) => { + dispatch({ type: 'FETCH_OPCODES_SUCCESS', payload: { code, address, index } }) + }) + }, []) + + useEffect(() => { + if (selectedItem !== assemblyItems.index) { + indexChanged(assemblyItems.index) + } + }, [assemblyItems.index]) + + const indexChanged = (index: number) => { + if (index < 0) return + let currentItem = refs.current[selectedItem] ? refs.current[selectedItem] : null + + if (currentItem) { + currentItem.removeAttribute('selected') + currentItem.removeAttribute('style') + if (currentItem.firstChild) { + currentItem.firstChild.removeAttribute('style') + } + const codeView = asmItemsRef.current + + currentItem = codeView.children[index] + currentItem.style.setProperty('border-color', 'var(--primary)') + currentItem.style.setProperty('border-style', 'solid') + currentItem.setAttribute('selected', 'selected') + codeView.scrollTop = currentItem.offsetTop - parseInt(codeView.offsetTop) + setSelectedItem(index) } + } - return ( -
-
-
-
- { - assemblyItems.display.map((item, i) => { - return
refs.current[i] = ref}>{item}
- }) - } -
-
-
+ return ( +
+
+
+
+ { + assemblyItems.display.map((item, i) => { + return
refs.current[i] = ref}>{item}
+ }) + } +
- ) +
+
+ ) } export default AssemblyItems \ No newline at end of file