Skip to content

Fix legendHeight setter in mount #170

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

Merged
merged 2 commits into from
Mar 6, 2022
Merged

Fix legendHeight setter in mount #170

merged 2 commits into from
Mar 6, 2022

Conversation

ChaDonSom
Copy link
Contributor

When VueEllipseProgress mounts, it might have legend disabled, in which case
the legendHeight property should be set to 0 rather than trying to access
the nonexistent legend template ref.

Thanks for your contribution!

By contributing to this project you agree to the contribution rules.

Quick checklist for code changes:

  • Created a new branch based on dev
  • All test and checks passed
  • No linting errors
  • New tests added (if necessary)
  • Docs updated (if necessary)

you can delete the above text, after all checks have passed


When VueEllipseProgress mounts, it might have `legend` disabled, in which case
the `legendHeight` property should be set to `0` rather than trying to access
the nonexistent `legend` template ref.
@setaman setaman self-requested a review March 4, 2022 06:09
@setaman
Copy link
Owner

setaman commented Mar 4, 2022

@ChaDonSom
that's a good caught, thank you! I will take a closer look at the PR soon

@setaman setaman self-assigned this Mar 4, 2022
Copy link
Owner

@setaman setaman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChaDonSom hey, indeed a very good caught.

I've also found out that it fails to set the height correctly if the hide-legend is initially true. Sadly your suggested change doesn't fix the actual issue, i still get the error:

TypeError: Cannot read properties of undefined (reading 'clientHeight')

That happens for example if data is used. But it isn't a problem at all and can be easily fixed. I would really like you to add the following helper method just right after the computed and use this method in the watcher and in mounted to consistently and safely update the height:

methods: {
    updateLegendHeight() {
      this.$nextTick(() => {
        this.legendHeight = this.hideLegend ? 0 : this.$refs.legend?.clientHeight ?? 0;
      });
    },
  },

@setaman setaman added the bug Something isn't working label Mar 5, 2022
@ChaDonSom
Copy link
Contributor Author

Ah, so sorry, I should've caught that if I had actually run the tests and/or pulled the project locally and manually tested it. I shouldn't have assumed it was that simple of a fix! 😵

I've implemented the suggested method and used it in mounted and in the hideLegend watcher. Hopefully this will work.

Thank you for your patience and understanding!

@setaman
Copy link
Owner

setaman commented Mar 6, 2022

This looks solid. Many thanks for your contribution! It will be released soon.

The tests fail because of the ?? operator. I need to tweak the config.

@setaman setaman merged commit dd2164b into setaman:v2-dev Mar 6, 2022
@ChaDonSom ChaDonSom deleted the v2-dev branch June 4, 2022 00:57
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
None yet
Development

Successfully merging this pull request may close these issues.

2 participants