fix(ui): fix bug report steps radius
This commit is contained in:
parent
1793cd16bf
commit
aae5f366c2
3 changed files with 11 additions and 4 deletions
|
|
@ -46,6 +46,12 @@ function Steps({ xrayProps, notes, members }: Props) {
|
|||
bugReportStore.resetSteps();
|
||||
};
|
||||
|
||||
React.useEffect(() => {
|
||||
if (bugReportStore.sessionEventSteps.length < RADIUS && bugReportStore.sessionEventSteps.length > 0) {
|
||||
setRadius(bugReportStore.sessionEventSteps.length);
|
||||
}
|
||||
}, [bugReportStore.sessionEventSteps])
|
||||
|
||||
return (
|
||||
<div>
|
||||
<SectionTitle>Steps to reproduce</SectionTitle>
|
||||
|
|
@ -63,7 +69,7 @@ function Steps({ xrayProps, notes, members }: Props) {
|
|||
STEPS
|
||||
<div id="pdf-ignore">
|
||||
{timePointer > 0 ? (
|
||||
<StepRadius pickRadius={stepPickRadius} setRadius={setRadius} />
|
||||
<StepRadius pickRadius={stepPickRadius} setRadius={setRadius} stepsNum={bugReportStore.sessionEventSteps.length}/>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@ import { Tooltip } from 'UI'
|
|||
interface Props {
|
||||
pickRadius: number;
|
||||
setRadius: (v: number) => void;
|
||||
stepsNum: number;
|
||||
}
|
||||
|
||||
function StepRadius({ pickRadius, setRadius }: Props) {
|
||||
function StepRadius({ pickRadius, setRadius, stepsNum }: Props) {
|
||||
return (
|
||||
<div className="w-full flex items-center gap-4">
|
||||
<div className="border-b border-dotted border-gray-medium cursor-help">
|
||||
|
|
@ -18,7 +19,7 @@ function StepRadius({ pickRadius, setRadius }: Props) {
|
|||
<div className="flex items-center gap-1">
|
||||
<div
|
||||
className="rounded px-2 bg-light-blue-bg cursor-pointer hover:bg-teal-light"
|
||||
onClick={() => setRadius(pickRadius + 1)}
|
||||
onClick={() => pickRadius < Math.floor(stepsNum/2) ? setRadius(pickRadius + 1) : null}
|
||||
>
|
||||
+1
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ export function getClosestEventStep(time: number, arr: Step[]) {
|
|||
export const selectEventSteps = (steps: Step[], targetTime: number, radius: number) => {
|
||||
const { targetStep, index } = getClosestEventStep(targetTime, steps)
|
||||
|
||||
const stepsBeforeEvent = steps.slice(index - radius, index)
|
||||
const stepsBeforeEvent = steps.slice(Math.max(index - radius, 0), index)
|
||||
const stepsAfterEvent = steps.slice(index + 1, index + 1 + radius)
|
||||
|
||||
return [...stepsBeforeEvent, targetStep, ...stepsAfterEvent]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue