Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle click event using event.currentTarget in DataTable #6333

Merged
merged 4 commits into from
Sep 10, 2024

Conversation

KumJungMin
Copy link
Contributor

@KumJungMin KumJungMin commented Sep 4, 2024

Defect Fixes

Fixes: #6323

How to reproduce Issue

  • First, paste code to <template> of CellEditDoc.vue
  • and you click cell, you can see the issue
<div class="card">
    <DataTable
        :value="products"
        editMode="cell"
        selectionMode="single"
        @cell-edit-complete="onCellEditComplete"
        :pt="{
            table: { style: 'min-width: 50rem' },
            column: {
                bodycell: ({ state }) => ({
                    class: [{ 'pt-0 pb-0': state['d_editing'] }]
                })
            }
        }"
    >
        <Column v-for="col of columns" :key="col.field" :field="col.field" :header="col.header" style="width: 25%">
            <template #body="{ data, field }">
                <div>
                    {{ field === 'price' ? formatCurrency(data[field]) : data[field] }}
                </div>
            </template>
            <template #editor="{ data, field }">
                <div>{{ data[field] }} 1</div>
            </template>
        </Column>
    </DataTable>
</div>

  • If you look at the video at the bottom, you can see that focusElement is null when the slot element is clicked.
    For normal behavior, focusElement should exist.
issue.mov

How To Resolve

I change event handling target event.target to event.currentTarget

  • event.target references the clicked slot's internal element, which prevents finding the parent <tr> element.
  • event.currentTarget accurately points to the parent element that has the event handler attached.

issue resolved video

resolved.mov

Copy link

vercel bot commented Sep 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
primevue ⬜️ Ignored (Inspect) Visit Preview Sep 4, 2024 9:15am
primevue-v3 ⬜️ Ignored (Inspect) Visit Preview Sep 4, 2024 9:15am

@KumJungMin KumJungMin marked this pull request as ready for review September 4, 2024 09:00
@KumJungMin KumJungMin changed the title fix: change click event handling by using event.currentTarget fix: handle click event using event.currentTarget in DataTable Sep 4, 2024
@tugcekucukoglu tugcekucukoglu merged commit 08340e2 into primefaces:master Sep 10, 2024
7 checks passed
@KumJungMin KumJungMin deleted the fix/issue-6323 branch September 10, 2024 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataTable: Cannot set properties of null (setting 'tabIndex')
2 participants