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

Changing the number of items per page fails #3667

Closed
4 of 11 tasks
filipegiusti opened this issue Feb 14, 2025 · 4 comments · Fixed by #3675
Closed
4 of 11 tasks

Changing the number of items per page fails #3667

filipegiusti opened this issue Feb 14, 2025 · 4 comments · Fixed by #3675
Labels
Bug Something isn't working

Comments

@filipegiusti
Copy link
Contributor

filipegiusti commented Feb 14, 2025

Describe the bug

The per page links generated don't respect the current loaded resource.

Image

And this causes changing the per page option to raise an unhandled exception or to show a "can't load has many association" error.

Reproduction repository for the bug

https://github.com/filipegiusti/per-page-bug

http://localhost:3000/avo/resources/coached_contacts/1

Steps to use in the reproduction repository

Steps to reproduce the behavior:

  1. Add a Contact on http://localhost:3000/avo/resources/contacts/new
  2. Add an Activity on http://localhost:3000/avo/resources/activities/new
  3. Go to http://localhost:3000/avo/resources/coached_contacts/1 or to http://localhost:3000/avo/resources/coached_contacts/1/activities
  4. Change the per page number of Activities
  5. See error

Expected behavior & Actual behavior

The per page attribute should change and the items should display.

The actual behavior is the error "Failed to load has many field show activities frame".

System configuration

Avo version: 3.17.6
Rails version: 7.2.2.1
Ruby version: 3.3.1

License type:

  • Community
  • Pro
  • Advanced

Are you using Avo monkey patches, overriding views or view components?

  • Yes. If so, please post code samples.
  • No

Screenshots or screen recordings

Image

Additional context

We do have both Resources::Contact and Resources::CoachedContact and the later uses self.model_class = Contact. In the same vein we have Resources::Activity and Resources::ContactActivity.

I was able to track down the issue to https://github.com/avo-hq/avo/blob/main/app/components/avo/paginator_component.rb#L15 the @parent_record is a Contact and the resource is a ContactActivity but the parent resource is a CoachedContact.

This wouldn't be so impactful to us if #2661 existed as we could put in sane defaults.

Impact

  • High impact (It makes my app un-usable.)
  • Medium impact (I'm annoyed, but I'll live.)
  • Low impact (It's really a tiny thing that I could live with.)

Urgency

  • High urgency (I can't continue development without it.)
  • Medium urgency (I found a workaround, but I'd love to have it fixed.)
  • Low urgency (It can wait. I just wanted you to know about it.)
@Paul-Bob
Copy link
Contributor

I hope that as I've tracked down the bug it's enough that it doesn't need a reproduction repository but let me know otherwise.

Hi @filipegiusti,

A reproduction repository isn't necessary if the issue can be easily reproduced at main avo demo.

If that's the case, please provide the steps to reproduce the issue there.

We always need a clear way to replicate issues to ensure we focus on the correct fix.

If a reproduction repository is required, you can follow this quick guide:
How to create a reproduction repository.

It should only take a couple of minutes to set up.

Thank you!

@Paul-Bob Paul-Bob added the Waiting on Reproduction Pending reproduction repository or detailed reproduction steps to proceed with issue resolution. label Feb 17, 2025
@filipegiusti
Copy link
Contributor Author

@Paul-Bob I've updated with a reproduction repository, let me know if you need anything else from me.

@Paul-Bob Paul-Bob added Bug Something isn't working and removed Waiting on Reproduction Pending reproduction repository or detailed reproduction steps to proceed with issue resolution. labels Feb 19, 2025
@Paul-Bob Paul-Bob moved this to In Progress in Issues Feb 19, 2025
@Paul-Bob
Copy link
Contributor

Thank for the update @filipegiusti

I have reproduced the issue, identified the problem, and submitted a PR with a fix. The reproduction repository was very helpful.

@github-project-automation github-project-automation bot moved this from In Progress to Done in Issues Feb 19, 2025
@filipegiusti
Copy link
Contributor Author

@Paul-Bob thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants