range-slider-input icon indicating copy to clipboard operation
range-slider-input copied to clipboard

range-slider__range has no style when the range input is initialized

Open s2i-evolution opened this issue 2 years ago • 4 comments

Hello,

I'm facing an issue when i want to use the range input. In fact it work normally but at the init the .range-slider__range has no style left & width, so the range bg is full width.

I'm using the 2.4.3 package

range input

My code :

var delta = 5000;
var minBudget = $('input[name="minBudget"]').val() ? parseInt($('input[name="minBudget"]').val()) + delta : 150000;
var maxBudget = $('input[name="maxBudget"]').val() ? parseInt($('input[name="maxBudget"]').val()) - delta : 550000;
const rangeSliderElement = rangeSlider(document.querySelector('#bugdet_slider'), {
  min: 50000,
  max: 800000,
  step: 1000,
  value: [minBudget, maxBudget],
  onInput: v => {
    value = v
    update()
  },
});

I have tested with a simplier declaration but it was the same

rangeSlider(document.querySelector('#bugdet_slider'));

s2i-evolution avatar Feb 01 '23 10:02 s2i-evolution

I can't reproduce this behavior with the provided information. This could be due to the HTML element that you're selecting, or may be due to the parent(s) of that element.

n3r4zzurr0 avatar Mar 06 '23 03:03 n3r4zzurr0

+1, the same issue

Probably it happens when the component is hidden with display: none on a parent which switches into display: block using state of a parent component. I had to unmount the component when it's hidden and mount back when it's visible and it helped.

Also you could fix with dispatching resize event on parent block using ref after some timeout when it gets initialized with the broken range styles.

Cheers

mekedron avatar Apr 18 '23 14:04 mekedron

I also found the same issue with a component inside a hidden parent.

rubenbristian avatar Sep 14 '23 07:09 rubenbristian

window.onload = function() {

Actually window onload have helped me to fix this problem, idk what was the reason of initialization failure

hehded avatar Nov 23 '23 08:11 hehded