Skip to content

Commit 6bb0f4a

Browse files
committed
Merge branch 'v4' into feature/dcc-refactor-textarea-tooltip
2 parents e0e3a60 + 391f0c8 commit 6bb0f4a

File tree

8 files changed

+53
-278
lines changed

8 files changed

+53
-278
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
88

99
- Dropdown API changes
1010
* default value of optionHeight is now 'auto' which supports text wrapping of lengthy text on small screens; you can still specify a numeric pixel height if desired
11-
* new `localizations` prop to customize strings used within the component
11+
* new `labels` prop to customize strings used within the component
1212
* default value for closeOnSelect is now `True` for single-select dropdowns and `False` for multi-select
1313

1414
- Slider API changes

components/dash-core-components/src/components/Tooltip.react.js

Lines changed: 0 additions & 260 deletions
This file was deleted.

components/dash-core-components/src/components/css/sliders.css

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77
touch-action: none;
88
width: 100%;
99
height: 14px;
10-
padding: 8px 0 28px 0;
10+
padding: 18px 0 18px 0;
1111
box-sizing: border-box;
1212
/* Override Radix's default margin/padding behavior */
1313
--radix-slider-thumb-width: 16px;
1414
}
1515

16+
.dash-slider-root.has-marks {
17+
padding: 8px 0 28px 0;
18+
}
19+
1620
.dash-slider-root[data-orientation='vertical'].has-marks {
1721
padding-bottom: 0px;
1822
}
@@ -167,7 +171,7 @@
167171
.dash-slider-container {
168172
display: flex;
169173
align-items: center;
170-
gap: 12px;
174+
gap: 16px;
171175
width: 100%;
172176
}
173177

@@ -184,7 +188,7 @@
184188
}
185189

186190
.dash-range-slider-min-input {
187-
min-width: 64px;
191+
text-align: center;
188192
}
189193

190194
.dash-range-slider-max-input {
@@ -193,7 +197,7 @@
193197

194198
.dash-range-slider-input {
195199
width: 64px;
196-
margin-top: 8px;
200+
text-align: center;
197201
-webkit-appearance: textfield;
198202
-moz-appearance: textfield;
199203
appearance: textfield;

components/dash-core-components/src/fragments/RangeSlider.tsx

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,35 @@ export default function RangeSlider(props: RangeSliderProps) {
166166
});
167167
}, [min, max, processedMarks, step, sliderWidth]);
168168

169+
// Calculate dynamic input width based on digits needed and container size
170+
const inputWidth = useMemo(() => {
171+
if (!sliderWidth) {
172+
return '64px'; // fallback to current width
173+
}
174+
175+
// Count digits needed for min and max values
176+
const maxDigits = Math.max(
177+
String(Math.floor(Math.abs(minMaxValues.max_mark))).length,
178+
String(Math.floor(Math.abs(minMaxValues.min_mark))).length
179+
);
180+
181+
// Add 1 for minus sign if min is negative
182+
const totalChars = maxDigits + (minMaxValues.min_mark < 0 ? 1 : 0);
183+
184+
// Calculate width as percentage of container (5% min, 15% max)
185+
/* eslint-disable no-magic-numbers */
186+
const minWidth = sliderWidth * 0.05;
187+
const maxWidth = sliderWidth * 0.15;
188+
const charBasedWidth = totalChars * 12; // approx 12px per character
189+
/* eslint-enable no-magic-numbers */
190+
191+
const calculatedWidth = Math.max(
192+
minWidth,
193+
Math.min(maxWidth, charBasedWidth)
194+
);
195+
return `${calculatedWidth}px`;
196+
}, [sliderWidth, minMaxValues.min_mark, minMaxValues.max_mark]);
197+
169198
const handleValueChange = (newValue: number[]) => {
170199
let adjustedValue = newValue;
171200

@@ -203,6 +232,7 @@ export default function RangeSlider(props: RangeSliderProps) {
203232
<input
204233
type="number"
205234
className="dash-input-container dash-range-slider-input dash-range-slider-min-input"
235+
style={{width: inputWidth}}
206236
value={value[0] ?? ''}
207237
onChange={e => {
208238
const inputValue = e.target.value;
@@ -263,7 +293,8 @@ export default function RangeSlider(props: RangeSliderProps) {
263293
{showInputs && !vertical && (
264294
<input
265295
type="number"
266-
className="dash-input-container dash-range-slider-input dash-range-slider-max-input"
296+
className="dash-input-container dash-range-slider-input dash-range-slider-max-input"
297+
style={{width: inputWidth}}
267298
value={value[value.length - 1] ?? ''}
268299
onChange={e => {
269300
const inputValue = e.target.value;

components/dash-core-components/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ export interface DropdownProps extends BaseComponentProps<DropdownProps> {
416416
style?: React.CSSProperties;
417417

418418
/**
419-
* Translations for customizing text contained within this component.
419+
* Text for customizing the labels rendered by this component.
420420
*/
421421
labels?: {
422422
select_all?: string;

0 commit comments

Comments
 (0)