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 table column getColumnIndex undefined bug #16782

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

406087475
Copy link

Fix table column getColumnIndex undefined bug

Please make sure these boxes are checked before submitting your PR, thank you!

  • Make sure you follow contributing guide English | (中文 | Español | Français).
  • Make sure you are merging your commits to dev branch.
  • Add some descriptions and refer to relative issues for your PR.

Fix table column getColumnIndex undefined bug
Copy link

👋 @406087475, seems like this is your first time contribution to element-plus.

  • Please make sure that you have read our guidelines and code of conduct before making a contribution.
  • You can comment with /label Components:[component_name] to add a label for which component you are working on.
  • You may join our Discord for staying tuned.

@pull-request-triage pull-request-triage bot added 1st contribution Their very first contribution Needs Review labels May 8, 2024
Copy link

github-actions bot commented May 8, 2024

Copy link

github-actions bot commented May 8, 2024

Hello @406087475, thank you for contributing to element-plus, please see our guideline to see how to make contribution

@btea
Copy link
Collaborator

btea commented May 8, 2024

Thank you for your contribution, but it is duplicated with #16781.

@Liao-js
Copy link
Contributor

Liao-js commented May 9, 2024

Can you provide a use case scenario where the error occurs?

@Liao-js
Copy link
Contributor

Liao-js commented May 9, 2024

I will close my PR

@ttionya
Copy link

ttionya commented Jun 4, 2024

Hi, Is this issue still being progressed?

@btea
Copy link
Collaborator

btea commented Jun 4, 2024

@ttionya Hi, can you provide a reproducible example? We have not encountered the corresponding scenario.

@ttionya
Copy link

ttionya commented Jun 4, 2024

@btea ,

Before providing reproducible code, I would like to confirm a syntax first. I have a scenario where I use v-if and v-else to control whether an el-table-column is displayed. Is this a valid approach?

<el-table-column ... v-if="condition" />
<el-table-column ... v-else />

@btea
Copy link
Collaborator

btea commented Jun 4, 2024

According to the example you provided, you are displaying two different columns under two different conditions?

@ttionya
Copy link

ttionya commented Jun 4, 2024

According to the example you provided, you are displaying two different columns under two different conditions?

Yes, and this condition is maintained in the store.

@btea
Copy link
Collaborator

btea commented Jun 4, 2024

This is fine if the corresponding fields are different. If it is the same field, and different content is rendered under different conditions, then you can render it according to the condition in the default slot.

@ttionya
Copy link

ttionya commented Jun 4, 2024

This is fine if the corresponding fields are different. If it is the same field, and different content is rendered under different conditions, then you can render it according to the condition in the default slot.

Thank you for your quick response.

Perhaps indeed there is an issue with my syntax, the prop fields of the two el-table-column are the same, I can indeed write them in the default slot. But I still want to ask, according to the following syntax, should this error not occur? But the error still persists.

<el-table-column prop="notname" v-if="condition"> <!-- prop is not name -->
  <template v-slot="{ row }">
    <el-link>{{ row.name }}</el-link> <!-- use row.name -->
  </template>
</el-table-column>
<el-table-column prop="name" v-else />

@btea
Copy link
Collaborator

btea commented Jun 4, 2024

I tested a simple example and it is normal. link

@ttionya
Copy link

ttionya commented Jun 4, 2024

I tested a simple example and it is normal. link

Yes, this is not an error that would occur in a simple scenario, otherwise others would have reported it already. :)

Briefly describe the reproduction method, if necessary, I can create a reproducible code example. The specific scenario is that when keepalive is used and it is in an inactive state, the condition changes, then clear the include of keepalive (such as logout), it triggers the onBeforeUnmount event of el-table-column, and then an error is reported.

@btea
Copy link
Collaborator

btea commented Jun 4, 2024

Oh, it seems a bit complicated according to your description. If you have time, please create a repository and provide the simplest reproducible code. Thanks!

@ttionya
Copy link

ttionya commented Jun 4, 2024

Oh, it seems a bit complicated according to your description. If you have time, please create a repository and provide the simplest reproducible code. Thanks!

@btea Hi, https://github.com/ttionya/element-plus-table-error-repro is a simple example to reproduce the issue. I am happy to discuss any questions. Looking forward to the issue being resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants