Skip to content

Commit cc21d09

Browse files
authored
Merge pull request #3532 from plotly/bugfix/rc3-feedback
Bugfix: `v4.0.0rc3` feedback
2 parents 07c4b12 + ca3d3cd commit cc21d09

File tree

21 files changed

+425
-347
lines changed

21 files changed

+425
-347
lines changed

components/dash-core-components/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ module.exports = {
3333
// Disable caching to ensure TypeScript type changes are always picked up
3434
cache: false,
3535
// Limit workers in CI to prevent out-of-memory errors
36-
maxWorkers: process.env.CI ? 2 : undefined,
36+
maxWorkers: 2,
3737
};

components/dash-core-components/src/components/Input.tsx

Lines changed: 12 additions & 233 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ import React, {
1111
import uniqid from 'uniqid';
1212
import fastIsNumeric from 'fast-isnumeric';
1313
import LoadingElement from '../utils/_LoadingElement';
14-
import {PersistedProps, PersistenceTypes} from '../types';
14+
import {
15+
HTMLInputTypes,
16+
InputProps,
17+
PersistedProps,
18+
PersistenceTypes,
19+
} from '../types';
1520
import './css/input.css';
1621

1722
const isNumeric = (val: unknown): val is number => fastIsNumeric(val);
@@ -20,238 +25,6 @@ const convert = (val: unknown) => (isNumeric(val) ? +val : NaN);
2025
const isEquivalent = (v1: number, v2: number) =>
2126
v1 === v2 || (isNaN(v1) && isNaN(v2));
2227

23-
export enum HTMLInputTypes {
24-
// Only allowing the input types with wide browser compatibility
25-
'text' = 'text',
26-
'number' = 'number',
27-
'password' = 'password',
28-
'email' = 'email',
29-
'range' = 'range',
30-
'search' = 'search',
31-
'tel' = 'tel',
32-
'url' = 'url',
33-
'hidden' = 'hidden',
34-
}
35-
36-
type InputProps = {
37-
/**
38-
* The value of the input
39-
*/
40-
value?: string | number;
41-
/**
42-
* If true, changes to input will be sent back to the Dash server only on enter or when losing focus.
43-
* If it's false, it will send the value back on every change.
44-
* If a number, it will not send anything back to the Dash server until the user has stopped
45-
* typing for that number of seconds.
46-
*/
47-
debounce?: boolean | number;
48-
/**
49-
* A hint to the user of what can be entered in the control . The placeholder text must not contain carriage returns or line-feeds. Note: Do not use the placeholder attribute instead of a <label> element, their purposes are different. The <label> attribute describes the role of the form element (i.e. it indicates what kind of information is expected), and the placeholder attribute is a hint about the format that the content should take. There are cases in which the placeholder attribute is never displayed to the user, so the form must be understandable without it.
50-
*/
51-
placeholder?: string | number;
52-
/**
53-
* Number of times the `Enter` key was pressed while the input had focus.
54-
*/
55-
n_submit?: number;
56-
/**
57-
* Last time that `Enter` was pressed.
58-
*/
59-
n_submit_timestamp?: number;
60-
/**
61-
* Provides a hint to the browser as to the type of data that might be
62-
* entered by the user while editing the element or its contents.
63-
*/
64-
inputMode?: /**
65-
* Alphanumeric, non-prose content such as usernames and passwords.
66-
*/
67-
| 'verbatim'
68-
/**
69-
* Latin-script input in the user's preferred language with typing aids such as text prediction enabled. For human-to-computer communication such as search boxes.
70-
*/
71-
| 'latin'
72-
/**
73-
* As latin, but for human names.
74-
*/
75-
| 'latin-name'
76-
/**
77-
* As latin, but with more aggressive typing aids. For human-to-human communication such as instant messaging or email.
78-
*/
79-
| 'latin-prose'
80-
/**
81-
* As latin-prose, but for the user's secondary languages.
82-
*/
83-
| 'full-width-latin'
84-
/**
85-
* Kana or romaji input, typically hiragana input, using full-width characters, with support for converting to kanji. Intended for Japanese text input.
86-
*/
87-
| 'kana'
88-
/**
89-
* Katakana input, using full-width characters, with support for converting to kanji. Intended for Japanese text input.
90-
*/
91-
| 'katakana'
92-
/**
93-
* Numeric input, including keys for the digits 0 to 9, the user's preferred thousands separator character, and the character for indicating negative numbers. Intended for numeric codes (e.g. credit card numbers). For actual numbers, prefer using type="number"
94-
*/
95-
| 'numeric'
96-
/**
97-
* Telephone input, including asterisk and pound key. Use type="tel" if possible instead.
98-
*/
99-
| 'tel'
100-
/**
101-
* Email input. Use type="email" if possible instead.
102-
*/
103-
| 'email'
104-
/**
105-
* URL input. Use type="url" if possible instead.
106-
*/
107-
| 'url';
108-
/**
109-
* This attribute indicates whether the value of the control can be automatically completed by the browser.
110-
*/
111-
autoComplete?: string;
112-
/**
113-
* This attribute indicates that the user cannot modify the value of the control. The value of the attribute is irrelevant. If you need read-write access to the input value, do not add the "readonly" attribute. It is ignored if the value of the type attribute is hidden, range, color, checkbox, radio, file, or a button type (such as button or submit).
114-
* readOnly is an HTML boolean attribute - it is enabled by a boolean or
115-
* 'readOnly'. Alternative capitalizations `readonly` & `READONLY`
116-
* are also acccepted.
117-
*/
118-
readOnly?: boolean | 'readOnly' | 'readonly' | 'READONLY';
119-
/**
120-
* This attribute specifies that the user must fill in a value before submitting a form. It cannot be used when the type attribute is hidden, image, or a button type (submit, reset, or button). The :optional and :required CSS pseudo-classes will be applied to the field as appropriate.
121-
* required is an HTML boolean attribute - it is enabled by a boolean or
122-
* 'required'. Alternative capitalizations `REQUIRED`
123-
* are also acccepted.
124-
*/
125-
required?: boolean | 'required' | 'REQUIRED';
126-
/**
127-
* The element should be automatically focused after the page loaded.
128-
* autoFocus is an HTML boolean attribute - it is enabled by a boolean or
129-
* 'autoFocus'. Alternative capitalizations `autofocus` & `AUTOFOCUS`
130-
* are also acccepted.
131-
*/
132-
autoFocus?: boolean | 'autoFocus' | 'autofocus' | 'AUTOFOCUS';
133-
/**
134-
* If true, the input is disabled and can't be clicked on.
135-
* disabled is an HTML boolean attribute - it is enabled by a boolean or
136-
* 'disabled'. Alternative capitalizations `DISABLED`
137-
*/
138-
disabled?: boolean | 'disabled' | 'DISABLED';
139-
/**
140-
* Identifies a list of pre-defined options to suggest to the user.
141-
* The value must be the id of a <datalist> element in the same document.
142-
* The browser displays only options that are valid values for this
143-
* input element.
144-
* This attribute is ignored when the type attribute's value is
145-
* hidden, checkbox, radio, file, or a button type.
146-
*/
147-
list?: string;
148-
/**
149-
* This Boolean attribute indicates whether the user can enter more than one value. This attribute applies when the type attribute is set to email or file, otherwise it is ignored.
150-
*/
151-
multiple?: boolean;
152-
/**
153-
* Setting the value of this attribute to true indicates that the element needs to have its spelling and grammar checked. The value default indicates that the element is to act according to a default behavior, possibly based on the parent element's own spellcheck value. The value false indicates that the element should not be checked.
154-
*/
155-
spellCheck?: boolean | 'true' | 'false';
156-
/**
157-
* The name of the control, which is submitted with the form data.
158-
*/
159-
name?: string;
160-
/**
161-
* The minimum (numeric or date-time) value for this item, which must not be greater than its maximum (max attribute) value.
162-
*/
163-
min?: string | number;
164-
/**
165-
* The maximum (numeric or date-time) value for this item, which must not be less than its minimum (min attribute) value.
166-
*/
167-
max?: string | number;
168-
/**
169-
* Works with the min and max attributes to limit the increments at which a numeric or date-time value can be set. It can be the string any or a positive floating point number. If this attribute is not set to any, the control accepts only values at multiples of the step value greater than the minimum.
170-
*/
171-
step?: string | number;
172-
/**
173-
* If the value of the type attribute is text, email, search, password, tel, or url, this attribute specifies the minimum number of characters (in Unicode code points) that the user can enter. For other control types, it is ignored.
174-
*/
175-
minLength?: string | number;
176-
/**
177-
* If the value of the type attribute is text, email, search, password, tel, or url, this attribute specifies the maximum number of characters (in UTF-16 code units) that the user can enter. For other control types, it is ignored. It can exceed the value of the size attribute. If it is not specified, the user can enter an unlimited number of characters. Specifying a negative number results in the default behavior (i.e. the user can enter an unlimited number of characters). The constraint is evaluated only when the value of the attribute has been changed.
178-
*/
179-
maxLength?: string | number;
180-
/**
181-
* A regular expression that the control's value is checked against. The pattern must match the entire value, not just some subset. Use the title attribute to describe the pattern to help the user. This attribute applies when the value of the type attribute is text, search, tel, url, email, or password, otherwise it is ignored. The regular expression language is the same as JavaScript RegExp algorithm, with the 'u' parameter that makes it treat the pattern as a sequence of unicode code points. The pattern is not surrounded by forward slashes.
182-
*/
183-
pattern?: string;
184-
/**
185-
* The offset into the element's text content of the first selected character. If there's no selection, this value indicates the offset to the character following the current text input cursor position (that is, the position the next character typed would occupy).
186-
*/
187-
selectionStart?: string;
188-
/**
189-
* The offset into the element's text content of the last selected character. If there's no selection, this value indicates the offset to the character following the current text input cursor position (that is, the position the next character typed would occupy).
190-
*/
191-
selectionEnd?: string;
192-
/**
193-
* The direction in which selection occurred. This is "forward" if the selection was made from left-to-right in an LTR locale or right-to-left in an RTL locale, or "backward" if the selection was made in the opposite direction. On platforms on which it's possible this value isn't known, the value can be "none"; for example, on macOS, the default direction is "none", then as the user begins to modify the selection using the keyboard, this will change to reflect the direction in which the selection is expanding.
194-
*/
195-
selectionDirection?: string;
196-
/**
197-
* Number of times the input lost focus.
198-
*/
199-
n_blur?: number;
200-
/**
201-
* Last time the input lost focus.
202-
*/
203-
n_blur_timestamp?: number;
204-
/**
205-
* The initial size of the control. This value is in pixels unless the value of the type attribute is text or password, in which case it is an integer number of characters. Starting in, this attribute applies only when the type attribute is set to text, search, tel, url, email, or password, otherwise it is ignored. In addition, the size must be greater than zero. If you do not specify a size, a default value of 20 is used.' simply states "the user agent should ensure that at least that many characters are visible", but different characters can have different widths in certain fonts. In some browsers, a certain string with x characters will not be entirely visible even if size is defined to at least x.
206-
*/
207-
size?: string;
208-
/**
209-
* The input's inline styles
210-
*/
211-
style?: React.CSSProperties;
212-
/**
213-
* The class of the input element
214-
*/
215-
className?: string;
216-
/**
217-
* The ID of this component, used to identify dash components
218-
* in callbacks. The ID needs to be unique across all of the
219-
* components in an app.
220-
*/
221-
id?: string;
222-
/**
223-
* Dash-assigned callback that gets fired when the value changes.
224-
*/
225-
setProps: (props: Partial<InputProps>) => void;
226-
/**
227-
* Used to allow user interactions in this component to be persisted when
228-
* the component - or the page - is refreshed. If `persisted` is truthy and
229-
* hasn't changed from its previous value, a `value` that the user has
230-
* changed while using the app will keep that change, as long as
231-
* the new `value` also matches what was given originally.
232-
* Used in conjunction with `persistence_type`.
233-
*/
234-
persistence?: boolean | string | number;
235-
/**
236-
* Properties whose user interactions will persist after refreshing the
237-
* component or the page. Since only `value` is allowed this prop can
238-
* normally be ignored.
239-
*/
240-
persisted_props?: PersistedProps[];
241-
/**
242-
* Where persisted user changes will be stored:
243-
* memory: only kept in memory, reset on page refresh.
244-
* local: window.localStorage, data is kept after the browser quit.
245-
* session: window.sessionStorage, data is cleared once the browser quit.
246-
*/
247-
persistence_type?: PersistenceTypes;
248-
249-
/**
250-
* The type of control to render.
251-
*/
252-
type?: HTMLInputTypes;
253-
};
254-
25528
const inputProps = [
25629
'type',
25730
'placeholder',
@@ -289,12 +62,17 @@ function Input({
28962
type = HTMLInputTypes.text,
29063
inputMode = 'verbatim',
29164
n_blur = 0,
65+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
29266
n_blur_timestamp = -1,
29367
n_submit = 0,
68+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
29469
n_submit_timestamp = -1,
29570
debounce = false,
29671
step = 'any',
72+
autoComplete = 'off',
73+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
29774
persisted_props = [PersistedProps.value],
75+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
29876
persistence_type = PersistenceTypes.local,
29977
disabled,
30078
...props
@@ -470,6 +248,7 @@ function Input({
470248
type,
471249
inputMode,
472250
step,
251+
autoComplete,
473252
disabled: disabledAsBool,
474253
}) as Pick<InputHTMLAttributes<HTMLInputElement>, HTMLInputProps>;
475254

components/dash-core-components/src/components/RadioItems.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ export default function RadioItems({
5454
options={sanitizedOptions}
5555
selected={isNil(value) ? [] : [value]}
5656
onSelectionChange={selection => {
57-
setProps({value: selection[selection.length - 1]});
57+
if (selection.length) {
58+
setProps({value: selection[selection.length - 1]});
59+
}
5860
}}
5961
{...stylingProps}
6062
/>

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
outline: none;
99
width: 100%;
1010
font-size: inherit;
11-
overflow: hidden;
11+
position: relative;
1212
accent-color: var(--Dash-Fill-Interactive-Strong);
1313
outline-color: var(--Dash-Fill-Interactive-Strong);
1414
}
@@ -20,23 +20,23 @@
2020
align-items: center;
2121
gap: calc(var(--Dash-Spacing) * 2);
2222
box-sizing: border-box;
23-
padding: 0 calc(var(--Dash-Spacing) * 2);
23+
padding: 0 12px;
2424
}
2525

26-
.dash-datepicker-input-wrapper:has(:nth-child(3)) {
27-
grid-template-columns: auto 1fr auto;
26+
.dash-datepicker-input-wrapper:has(> :nth-child(2)) {
27+
grid-template-columns: 1fr auto;
2828
}
2929

30-
.dash-datepicker-input-wrapper:has(:nth-child(4)) {
31-
grid-template-columns: auto 1fr auto auto;
30+
.dash-datepicker-input-wrapper:has(> :nth-child(3)) {
31+
grid-template-columns: 1fr auto auto;
3232
}
3333

34-
.dash-datepicker-input-wrapper:has(:nth-child(5)) {
35-
grid-template-columns: auto auto auto 1fr auto;
34+
.dash-datepicker-input-wrapper:has(> :nth-child(4)) {
35+
grid-template-columns: auto auto 1fr auto;
3636
}
3737

38-
.dash-datepicker-input-wrapper:has(:nth-child(6)) {
39-
grid-template-columns: auto auto auto 1fr auto auto;
38+
.dash-datepicker-input-wrapper:has(> :nth-child(5)) {
39+
grid-template-columns: auto auto 1fr auto auto;
4040
}
4141

4242
.dash-datepicker-input-wrapper,
@@ -55,6 +55,7 @@
5555
border-radius: 4px;
5656
padding: 0;
5757
background-color: inherit;
58+
color: inherit;
5859
}
5960

6061
.dash-datepicker-input::selection,
@@ -231,3 +232,8 @@
231232
width: 20px;
232233
height: 20px;
233234
}
235+
236+
/* Override Radix's position: fixed to use position: absolute when using custom container */
237+
div[data-radix-popper-content-wrapper]:has(.dash-datepicker-content) {
238+
position: absolute !important;
239+
}

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
grid-template-columns: auto 1fr;
2020
justify-items: start;
2121
align-items: center;
22-
gap: 8px;
22+
gap: calc(var(--Dash-Spacing) * 2);
2323
}
2424

25-
.dash-dropdown-grid-container:has(:nth-child(3)) {
25+
.dash-dropdown-grid-container:has(> :nth-child(3)) {
2626
grid-template-columns: auto 1fr auto;
2727
}
2828

29-
.dash-dropdown-grid-container:has(:nth-child(4)) {
29+
.dash-dropdown-grid-container:has(> :nth-child(4)) {
3030
grid-template-columns: auto 1fr auto auto;
3131
}
3232

@@ -212,3 +212,13 @@
212212
padding: calc(var(--Dash-Spacing) * 2) calc(var(--Dash-Spacing) * 3);
213213
box-shadow: 0 -1px 0 0 var(--Dash-Fill-Disabled) inset;
214214
}
215+
216+
/* Positioning container for the dropdown */
217+
.dash-dropdown-wrapper {
218+
position: relative;
219+
}
220+
221+
/* Override Radix's position: fixed to use position: absolute when using custom container */
222+
div[data-radix-popper-content-wrapper]:has(.dash-dropdown-content) {
223+
position: absolute !important;
224+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
position: relative;
44
display: inline-flex;
55
align-items: center;
6-
width: 170px; /* default input width */
6+
width: 100%;
77
height: 34px;
88
background: var(--Dash-Fill-Inverse-Strong);
99
border-radius: var(--Dash-Spacing);

0 commit comments

Comments
 (0)