diff --git a/src/main/webapp/src/pages/competition/editor/CMTMatchPanel.jsx b/src/main/webapp/src/pages/competition/editor/CMTMatchPanel.jsx index 3d88ca2..f8dc315 100644 --- a/src/main/webapp/src/pages/competition/editor/CMTMatchPanel.jsx +++ b/src/main/webapp/src/pages/competition/editor/CMTMatchPanel.jsx @@ -263,7 +263,7 @@ function MatchList({matches, cat, menuActions}) { - {activeMatch && } + {activeMatch && } } @@ -335,21 +335,21 @@ function BuildTree({treeData, matches, menuActions}) { {currentMatch?.matchSelect && - } + } } -function ScorePanel({matchId, match, menuActions}) { +function ScorePanel({matchId, matchs, match, menuActions}) { const onClickVoid = useRef(() => { }); return
- +
} -function ScorePanel_({matchId, match, menuActions, onClickVoid_}) { +function ScorePanel_({matchId, matchs, match, menuActions, onClickVoid_}) { const {sendRequest} = useWS() const setLoading = useLoadingSwitcher() @@ -359,6 +359,11 @@ function ScorePanel_({matchId, match, menuActions, onClickVoid_}) { const tableRef = useRef(null) const scoreRef = useRef([]) const lastScoreClick = useRef(null) + const scoreInRef = useRef(null) + + useEffect(() => { + scoreInRef.current = scoreIn; + }, [scoreIn]); useEffect(() => { menuActions.current.saveScore = (scoreRed, scoreBlue) => { @@ -407,9 +412,12 @@ function ScorePanel_({matchId, match, menuActions, onClickVoid_}) { const {matchId, round, comb} = lastScoreClick.current; lastScoreClick.current = null; - const scoreIn_ = String(scoreIn).trim() === "" ? -1000 : Number(scoreIn); + const scoreIn_ = String(scoreInRef.current).trim() === "" ? -1000 : Number(scoreInRef.current); + + const score = matchs.find(m => m.id === matchId).scores.find(s => s.n_round === round); + + console.log("Updating score", matchId, round, comb, scoreIn_, score); - const score = match.scores.find(s => s.n_round === round); let newScore; if (score) { if (comb === 1) @@ -478,6 +486,18 @@ function ScorePanel_({matchId, match, menuActions, onClickVoid_}) { setEnd(match.end); }, [match]); + useEffect(() => { + const handleClickOutside = (event) => { + if (inputRef.current && !inputRef.current.contains(event.target)) { + onClickVoid(); + } + }; + document.addEventListener("mousedown", handleClickOutside); + return () => { + document.removeEventListener("mousedown", handleClickOutside); + }; + }, []); + const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]') const o = [...tooltipTriggerList] o.map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl))