Skip to content

Commit

Permalink
Disable vote-button on drag start
Browse files Browse the repository at this point in the history
  • Loading branch information
ApsiV11 committed Nov 21, 2024
1 parent 0c274e3 commit 065f5f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/frontend/components/vote/Vote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export const Vote = () => {
const [availableCandidates, setAvailableCandidates] = useState<string[]>([])
const { t } = useTranslation('translation', { keyPrefix: 'voter.vote' })

const handleDragStart = () => {
setDisableVote(true)
}

const handleDragEnd = (result: DropResult<string>) => {
if (!result.destination) {
return
Expand Down Expand Up @@ -82,6 +86,7 @@ export const Vote = () => {
const [removed] = availableCandidates.splice(result.source.index, 1)
availableCandidates.splice(destinationIndex, 0, removed)
}
setDisableVote(false)
}

useEffect(() => {
Expand Down Expand Up @@ -175,7 +180,10 @@ export const Vote = () => {
<div className="my-3">
<b>{t('vote_instruction')}</b>
</div>
<DragDropContext onDragEnd={handleDragEnd}>
<DragDropContext
onDragStart={handleDragStart}
onDragEnd={handleDragEnd}
>
<Row>
<Col md={6}>
<h5>{t('selected_candidates')}</h5>
Expand Down
2 changes: 0 additions & 2 deletions tests/utils/voter-voting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export const selectCandidate = async (page: Page, candidateName: string) => {
}
)
await page.mouse.up()
await page.waitForTimeout(500)
}

export const deselectCandidate = async (page: Page, candidateName: string) => {
Expand All @@ -43,5 +42,4 @@ export const deselectCandidate = async (page: Page, candidateName: string) => {
}
)
await page.mouse.up()
await page.waitForTimeout(500)
}

0 comments on commit 065f5f9

Please sign in to comment.