Skip to content

Commit

Permalink
[fix] Defaults and fallback logic for web props
Browse files Browse the repository at this point in the history
  • Loading branch information
necolas committed Apr 12, 2023
1 parent 3e74ed0 commit 7638301
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 54 deletions.
5 changes: 4 additions & 1 deletion packages/react-native-web/src/exports/CheckBox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ const CheckBox: React.AbstractComponent<
checked: value,
disabled: disabled,
onChange: handleChange,
readOnly: readOnly || ariaReadOnly || other.accessibilityReadOnly,
readOnly:
readOnly === true ||
ariaReadOnly === true ||
other.accessibilityReadOnly === true,
ref: forwardedRef,
style: [styles.nativeControl, styles.cursorInherit],
type: 'checkbox'
Expand Down
10 changes: 3 additions & 7 deletions packages/react-native-web/src/exports/TextInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const TextInput: React.AbstractComponent<
placeholderTextColor,
readOnly = false,
returnKeyType,
rows = 1,
rows,
secureTextEntry = false,
selection,
selectTextOnFocus,
Expand Down Expand Up @@ -389,18 +389,14 @@ const TextInput: React.AbstractComponent<
if (editable != null) {
warnOnce('editable', 'editable is deprecated. Use readOnly.');
}
supportedProps.readOnly = readOnly || !editable;
supportedProps.readOnly = readOnly === true || editable === false;
if (numberOfLines != null) {
warnOnce(
'numberOfLines',
'TextInput numberOfLines is deprecated. Use rows.'
);
}
supportedProps.rows = multiline
? rows != null
? rows
: numberOfLines
: undefined;
supportedProps.rows = multiline ? (rows != null ? rows : numberOfLines) : 1;
supportedProps.spellCheck = spellCheck != null ? spellCheck : autoCorrect;
supportedProps.style = [
{ '--placeholderTextColor': placeholderTextColor },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('modules/createDOMProps', () => {
expect(_props).toMatchInlineSnapshot(`
{
"aria-activedescendant": "activedescendant",
"aria-atomic": true,
"aria-atomic": "activedescendant",
"aria-autocomplete": "list",
"aria-busy": true,
"aria-checked": true,
Expand Down Expand Up @@ -112,6 +112,7 @@ describe('modules/createDOMProps', () => {
"aria-setsize": 5,
"aria-sort": "ascending",
"aria-valuemax": 5,
"aria-valuemin": 0,
"aria-valuenow": 3,
"aria-valuetext": "3",
"className": "className",
Expand Down
Loading

0 comments on commit 7638301

Please sign in to comment.