mirror of
https://github.com/streamwall/streamwall.git
synced 2026-01-30 00:42:48 -05:00
Make clicking ids replace focused grid input
This commit is contained in:
@@ -217,6 +217,10 @@ function App({ wsEndpoint }) {
|
|||||||
return () => window.removeEventListener('mouseup', endDrag)
|
return () => window.removeEventListener('mouseup', endDrag)
|
||||||
}, [stateDoc, dragStart, dragEnd])
|
}, [stateDoc, dragStart, dragEnd])
|
||||||
|
|
||||||
|
const [focusedInputIdx, setFocusedInputIdx] = useState()
|
||||||
|
const handleFocusInput = useCallback(setFocusedInputIdx, [])
|
||||||
|
const handleBlurInput = useCallback(() => setFocusedInputIdx(), [])
|
||||||
|
|
||||||
const handleSetView = useCallback(
|
const handleSetView = useCallback(
|
||||||
(idx, streamId) => {
|
(idx, streamId) => {
|
||||||
const stream = streams.find((d) => d._id === streamId)
|
const stream = streams.find((d) => d._id === streamId)
|
||||||
@@ -284,6 +288,12 @@ function App({ wsEndpoint }) {
|
|||||||
const handleClickId = useCallback(
|
const handleClickId = useCallback(
|
||||||
(streamId) => {
|
(streamId) => {
|
||||||
navigator.clipboard.writeText(streamId)
|
navigator.clipboard.writeText(streamId)
|
||||||
|
|
||||||
|
if (focusedInputIdx !== undefined) {
|
||||||
|
handleSetView(focusedInputIdx, streamId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const availableIdx = range(gridCount * gridCount).find(
|
const availableIdx = range(gridCount * gridCount).find(
|
||||||
(i) => !sharedState.views[i].streamId,
|
(i) => !sharedState.views[i].streamId,
|
||||||
)
|
)
|
||||||
@@ -292,7 +302,7 @@ function App({ wsEndpoint }) {
|
|||||||
}
|
}
|
||||||
handleSetView(availableIdx, streamId)
|
handleSetView(availableIdx, streamId)
|
||||||
},
|
},
|
||||||
[gridCount, sharedState],
|
[gridCount, sharedState, focusedInputIdx],
|
||||||
)
|
)
|
||||||
|
|
||||||
const handleChangeCustomStream = useCallback((idx, customStream) => {
|
const handleChangeCustomStream = useCallback((idx, customStream) => {
|
||||||
@@ -387,6 +397,8 @@ function App({ wsEndpoint }) {
|
|||||||
isHighlighted={isDragHighlighted}
|
isHighlighted={isDragHighlighted}
|
||||||
onMouseDown={handleDragStart}
|
onMouseDown={handleDragStart}
|
||||||
onMouseEnter={setDragEnd}
|
onMouseEnter={setDragEnd}
|
||||||
|
onFocus={handleFocusInput}
|
||||||
|
onBlur={handleBlurInput}
|
||||||
onChangeSpace={handleSetView}
|
onChangeSpace={handleSetView}
|
||||||
onSetListening={handleSetListening}
|
onSetListening={handleSetListening}
|
||||||
onSetBlurred={handleSetBlurred}
|
onSetBlurred={handleSetBlurred}
|
||||||
@@ -471,7 +483,8 @@ function StreamLine({
|
|||||||
row: { label, source, title, link, notes, state, city },
|
row: { label, source, title, link, notes, state, city },
|
||||||
onClickId,
|
onClickId,
|
||||||
}) {
|
}) {
|
||||||
const handleClickId = useCallback(() => {
|
// Use mousedown instead of click event so a potential destination grid input stays focused.
|
||||||
|
const handleMouseDownId = useCallback(() => {
|
||||||
onClickId(id)
|
onClickId(id)
|
||||||
}, [onClickId, id])
|
}, [onClickId, id])
|
||||||
let location
|
let location
|
||||||
@@ -480,7 +493,7 @@ function StreamLine({
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<StyledStreamLine>
|
<StyledStreamLine>
|
||||||
<StyledId onClick={handleClickId} color={idColor(id)}>
|
<StyledId onMouseDown={handleMouseDownId} color={idColor(id)}>
|
||||||
{id}
|
{id}
|
||||||
</StyledId>
|
</StyledId>
|
||||||
<div>
|
<div>
|
||||||
@@ -512,6 +525,8 @@ function GridInput({
|
|||||||
isHighlighted,
|
isHighlighted,
|
||||||
onMouseDown,
|
onMouseDown,
|
||||||
onMouseEnter,
|
onMouseEnter,
|
||||||
|
onFocus,
|
||||||
|
onBlur,
|
||||||
onSetListening,
|
onSetListening,
|
||||||
onSetBlurred,
|
onSetBlurred,
|
||||||
onReloadView,
|
onReloadView,
|
||||||
@@ -519,12 +534,20 @@ function GridInput({
|
|||||||
onDevTools,
|
onDevTools,
|
||||||
}) {
|
}) {
|
||||||
const [editingValue, setEditingValue] = useState()
|
const [editingValue, setEditingValue] = useState()
|
||||||
const handleFocus = useCallback((ev) => {
|
const handleFocus = useCallback(
|
||||||
setEditingValue(ev.target.value)
|
(ev) => {
|
||||||
})
|
setEditingValue(ev.target.value)
|
||||||
const handleBlur = useCallback((ev) => {
|
onFocus(idx)
|
||||||
setEditingValue(undefined)
|
},
|
||||||
})
|
[onFocus, idx],
|
||||||
|
)
|
||||||
|
const handleBlur = useCallback(
|
||||||
|
(ev) => {
|
||||||
|
setEditingValue(undefined)
|
||||||
|
onBlur(idx)
|
||||||
|
},
|
||||||
|
[onBlur, idx],
|
||||||
|
)
|
||||||
const handleChange = useCallback(
|
const handleChange = useCallback(
|
||||||
(ev) => {
|
(ev) => {
|
||||||
const { value } = ev.target
|
const { value } = ev.target
|
||||||
|
|||||||
Reference in New Issue
Block a user