Skip to content

Commit

Permalink
refactor: improve variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
fterra-encora committed Mar 11, 2024
1 parent 595836b commit 98fc055
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ const mask = "#".repeat(placeholder.length);
const ariaLabel = `${props.parentTitle} ${datePartName}`;
const cdsTextInput = ref<InstanceType<typeof CDSTextInput> | null>(null);
const cdsTextInputRef = ref<InstanceType<typeof CDSTextInput> | null>(null);
watch(cdsTextInput, async (value) => {
if (value) {
watch(cdsTextInputRef, async (cdsTextInput) => {
if (cdsTextInput) {
// wait for the DOM updates to complete
await nextTick();
const input = value.shadowRoot?.querySelector("input");
const input = cdsTextInput.shadowRoot?.querySelector("input");
if (input) {
// display numeric keyboard on mobile devices
input.inputMode = "numeric";
Expand All @@ -64,7 +64,7 @@ watch(cdsTextInput, async (value) => {
<div class="input-group">
<cds-text-input
v-if="enabled"
ref="cdsTextInput"
ref="cdsTextInputRef"
:id="id"
:required="required"
:label="capitalizedDatePart"
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/components/forms/TextInputComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ const selectValue = (event: any) => {
isUserEvent.value = true
};
const cdsTextInput = ref<InstanceType<typeof CDSTextInput> | null>(null);
const cdsTextInputRef = ref<InstanceType<typeof CDSTextInput> | null>(null);
watch([cdsTextInput, () => props.numeric], async ([cdsTextInputValue]) => {
if (cdsTextInputValue) {
watch([cdsTextInputRef, () => props.numeric], async ([cdsTextInput]) => {
if (cdsTextInput) {
// wait for the DOM updates to complete
await nextTick();
const input = cdsTextInputValue.shadowRoot?.querySelector("input");
const input = cdsTextInput.shadowRoot?.querySelector("input");
if (input) {
// display either a numeric or an alphanumeric (default) keyboard on mobile devices
input.inputMode = props.numeric ? "numeric" : "text";
Expand All @@ -144,7 +144,7 @@ watch([cdsTextInput, () => props.numeric], async ([cdsTextInputValue]) => {
<div class="input-group">
<cds-text-input
v-if="enabled"
ref="cdsTextInput"
ref="cdsTextInputRef"
:id="id"
:required="required"
:label="label"
Expand Down

0 comments on commit 98fc055

Please sign in to comment.