Skip to content

Commit

Permalink
fix: datepicker placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
mlmoravek committed Oct 5, 2023
1 parent 344c6d5 commit 0daf99d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
14 changes: 12 additions & 2 deletions packages/oruga-next/src/components/datepicker/PickerWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,19 @@ const elementRef = computed(() =>
);
// use form input functionality for native input
const { checkHtml5Validity, onBlur, onFocus, onInvalid, isValid } =
const { checkHtml5Validity, onBlur, onFocus, onInvalid, isValid, isFocused } =
useInputHandler(elementRef, emits, picker.value);
/**
* Show input as text for placeholder,
* when placeholder and native value is given and input is not focused.
*/
const computedNativeType = computed(() =>
!picker.value.placeholder || props.nativeValue || isFocused.value
? props.nativeType
: "text",
);
/**
* When v-model is changed:
* 1. Update internal value.
Expand Down Expand Up @@ -230,7 +240,7 @@ defineExpose({
v-else
ref="nativeInputRef"
v-bind="inputBind"
:type="nativeType"
:type="computedNativeType"
autocomplete="off"
:model-value="nativeValue"
:min="nativeMin"
Expand Down
11 changes: 7 additions & 4 deletions packages/oruga-next/src/components/input/Input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ const props = defineProps({
* Input type, like native
* @values Any native input type, and textarea
*/
type: {
type: String,
default: "text",
},
type: { type: String, default: "text" },
/**
* Size of the control, optional
* @values small, medium, large
Expand Down Expand Up @@ -300,6 +297,12 @@ function rightIconClick(event: Event): void {
const isPasswordVisible = ref(false);
const inputType = ref(props.type);
// update inputType on type prop change
watch(
() => props.type,
(type) => (inputType.value = type),

Check warning on line 303 in packages/oruga-next/src/components/input/Input.vue

View check run for this annotation

Codecov / codecov/patch

packages/oruga-next/src/components/input/Input.vue#L303

Added line #L303 was not covered by tests
);
/** Current password-reveal icon name. */
const passwordVisibleIcon = computed(() =>
!isPasswordVisible.value ? "eye" : "eye-off",

Check warning on line 308 in packages/oruga-next/src/components/input/Input.vue

View check run for this annotation

Codecov / codecov/patch

packages/oruga-next/src/components/input/Input.vue#L308

Added line #L308 was not covered by tests
Expand Down

0 comments on commit 0daf99d

Please sign in to comment.