Skip to content

Commit

Permalink
fix(Input): supplement default value for cursor-color attr (#3272)
Browse files Browse the repository at this point in the history
* fix(Input): supplement default value for cursor-color attr

* test: update snapshots
  • Loading branch information
anlyyao authored Nov 12, 2024
1 parent b193a61 commit 79a7789
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/common/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import exp from 'constants';
import { prefix } from './config';
import { getWindowInfo, getAppBaseInfo, getDeviceInfo } from './wechat';

Expand Down Expand Up @@ -129,6 +128,10 @@ export const isDef = function (value: any): boolean {
return !isUndefined(value) && !isNull(value);
};

export const isIOS = function (): boolean {
return !!(deviceInfo?.system?.toLowerCase().search('ios') + 1);
};

export const addUnit = function (value?: string | number): string | undefined {
if (!isDef(value)) {
return undefined;
Expand Down
4 changes: 2 additions & 2 deletions src/input/__test__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ exports[`input props : clearable && label && suffix 1`] = `
confirmHold="{{false}}"
confirmType="done"
cursor="{{0}}"
cursorColor=""
cursorColor="#0052d9"
cursorSpacing="{{0}}"
disabled="{{null}}"
focus="{{false}}"
Expand Down Expand Up @@ -174,7 +174,7 @@ exports[`input slots : label 1`] = `
confirmHold="{{false}}"
confirmType="done"
cursor="{{0}}"
cursorColor=""
cursorColor="#0052d9"
cursorSpacing="{{0}}"
disabled="{{null}}"
focus="{{false}}"
Expand Down
3 changes: 2 additions & 1 deletion src/input/input.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SuperComponent, wxComponent } from '../common/src/index';
import config from '../common/config';
import props from './props';
import { getCharacterLength, calcIcon, isDef } from '../common/utils';
import { getCharacterLength, calcIcon, isDef, isIOS } from '../common/utils';

const { prefix } = config;
const name = `${prefix}-input`;
Expand Down Expand Up @@ -32,6 +32,7 @@ export default class Input extends SuperComponent {
classPrefix: name,
classBasePrefix: prefix,
showClearIcon: true,
defaultCursorColor: isIOS() ? '#0052d9' : 'default',
};

lifetimes = {
Expand Down
2 changes: 1 addition & 1 deletion src/input/input.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
confirm-type="{{confirmType}}"
confirm-hold="{{confirmHold}}"
cursor="{{cursor}}"
cursor-color="{{cursorColor}}"
cursor-color="{{cursorColor || defaultCursorColor}}"
cursor-spacing="{{cursorSpacing}}"
adjust-position="{{adjustPosition}}"
auto-focus="{{autoFocus}}"
Expand Down

0 comments on commit 79a7789

Please sign in to comment.