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

Setting generateLabelsUnits with Javascript not working #3

Closed
kla-ko opened this issue Nov 12, 2022 · 7 comments
Closed

Setting generateLabelsUnits with Javascript not working #3

kla-ko opened this issue Nov 12, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@kla-ko
Copy link

kla-ko commented Nov 12, 2022

I have the following setup:

import { useRef, useEffect } from 'react';
import './lib/tcrs-generated-labels.min.js';
import './lib/toolcool-range-slider.min.js'; 

export default function RangeSliderPro({ component, eventHandlers, appData, pageData, parentDataModel }) {
  
  const sliderRef = useRef(null);
  
  useEffect( ()=>{
    const slider = sliderRef.current;
    slider.value1 = 30;
    slider.generateLabels = true;
    slider.generateLabelsUnits = '%';

    return () => { 
      slider?.removeEventListener('change', onChange);
    }
    
  }, [] )
  
  return ( 
    <tc-range-slider ref={sliderRef}></tc-range-slider> 
  )
}

Issue: the statement slider.generateLabelsUnits = '%' shows no effect.

@toolcool-org toolcool-org added the bug Something isn't working label Nov 12, 2022
toolcool-org added a commit that referenced this issue Nov 13, 2022
@toolcool-org
Copy link
Collaborator

Fixed.

@kla-ko
Copy link
Author

kla-ko commented Nov 14, 2022

Got it working now, but only by looking into your tests.
The point is, that you've introduced the property units, instead of generateLabelsUnits, which would be consistent with generate-labels-units.

Regards,

@toolcool-org
Copy link
Collaborator

I have added it to the documentation in the "script" example on this page below the text "It is also possible to enable or disable generated labels programmatically:":
https://range-slider.toolcool.org/pages/auto-generated-labels.html

@toolcool-org
Copy link
Collaborator

generateLabelsUnits is indeed a better name, but it's kind of a breaking change. I don't think many people use this API now, so it's probably a good time to change it.

@kla-ko
Copy link
Author

kla-ko commented Nov 14, 2022

It would be better if all API properties can be derived from the <tc-range-slider- properties.
generate-labels --> generateLabels
generate-labels-units--> generateLabelsUnits, etc.

If you want to stay compatible (no breaking change), just allow both API parameters, units and generateLabelsUnits.

Do you want me to close this issue?

Regards,

@toolcool-org
Copy link
Collaborator

Let's close it for now.
Thank you for your great feedback!

@toolcool-org
Copy link
Collaborator

Just FYI - I added the following APIs:
slider.generateLabelsUnits = '%';
slider.generateLabelsTextColor = '#545454';

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

No branches or pull requests

2 participants