Craig-Creeger / react-likert-scale

A React component that renders a Likert scale. It is responsive and accessible.
Creative Commons Zero v1.0 Universal
8 stars 6 forks source link

Allow passing fieldsetId prop #1

Closed mathiscode closed 3 years ago

Craig-Creeger commented 3 years ago

Thanks for the contribution, @mathiscode . I like being able to set an id on the fieldset. What do you think about setting a ref on the fieldset instead? Out of curiosity, what is your use-case for the id?

Obviously, I have not done much to this repo in a long time, and would like to update it a bit and possibly convert it to use functional components and hooks.

mathiscode commented 3 years ago

A ref could be useful as well - my use-case got a bit convoluted, but the main issue was I was detecting the legend innerText to find the question for each particular scale, then doing some actions based on that. However, the question is internationalized so I couldn't rely on that, which led me to set an id with a hash of the English question. That solved my immediate problem.

I'm absolutely confident there was a better way to solve my problem, but client deadlines made me desperate. 😅

By the way, thank you for this project - I was dreading creating this from scratch!

Craig-Creeger commented 3 years ago

I will be upgrading the dependencies and adding in the ability to pass in a ref prop. Additionally, it will still support id, plus any other valid DOM element attribute. It should be backwards compatible with this version.

It will be done within the next couple of days.