You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[EuiRange] option to change/remove 20 tick limit #6807
Maximum of 20 ticks allowed
Spacing can get quite cramped with lots of ticks so we max out the number to 20.
While this is a fine limit in general, hardcoding it seems unnecessarily limiting. I'm working on a project with very wide range sliders (think full screen width) with very narrow ticks (labels are 1 character each), and it could easily fit many many more than 20 ticks that way.
Additionally, a hardcoded limit of 20 doesn't really help when the sliders is very short.
As such, I'd like to request an option to override this limit.
// Error out if there are too many ticks to render
if(sequence.length>20){
thrownewError(
`The number of ticks to render is too high (${sequence.length}), reduce the interval.`
);
}
Agreed that it seems pretty heavy-handed of us to simply throw/refuse to render the component instead of warning. Even if we were to throw, it should probably be more intelligently and we should detect whether or not ticks are actually cramped/overflowing first.
Just curious @bartvanheukelom, would you be interested in all in contributing to EUI to make your requested change? The easiest solution would probably be to change the throw to a simple console.warn instead.
#6829 updates this hard-coded limit to instead semi-intelligently use the width of the track to figure out how much space each tick has. If each tick has a width of less than 5px (which is ludicrously small and means something has gone very wrong), the component will throw/error.
If the available width per tick is less than 20px, we'll emit a console.warn instead just to let you know you may want to consider using a breakpoint utility hook to responsively customize your tickInterval.
I left those minimum widths in as static/hard-coded as I figured they were fairly safe buffers, but please feel free to leave another comment if you feel strongly they should be customizable as well.
Activity
cee-chen commentedon May 25, 2023
Linking to the relevant portion in our code:
eui/src/components/form/range/range_track.tsx
Lines 94 to 99 in 329eb41
Agreed that it seems pretty heavy-handed of us to simply throw/refuse to render the component instead of warning. Even if we were to throw, it should probably be more intelligently and we should detect whether or not ticks are actually cramped/overflowing first.
Just curious @bartvanheukelom, would you be interested in all in contributing to EUI to make your requested change? The easiest solution would probably be to change the
throwto a simpleconsole.warninstead.cee-chen commentedon Jun 6, 2023
#6829 updates this hard-coded limit to instead semi-intelligently use the width of the track to figure out how much space each tick has. If each tick has a width of less than 5px (which is ludicrously small and means something has gone very wrong), the component will throw/error.
If the available width per tick is less than 20px, we'll emit a
console.warninstead just to let you know you may want to consider using a breakpoint utility hook to responsively customize yourtickInterval.I left those minimum widths in as static/hard-coded as I figured they were fairly safe buffers, but please feel free to leave another comment if you feel strongly they should be customizable as well.