Issue with Vuetify password field: label overlaps with v-text-field

I'm currently working on a logging feature using Vuetify and Firebase. My goal is to hide the password input field but when I set the type as 'password' for the v-text-field, it causes 4 dots to overlap with the label of the password field and the word 'admin' to appear over the email field:

https://i.sstatic.net/3jfUM.jpg

Upon clicking any field, the $data pre shows that "admin" is being assigned to both password and email fields. I've attempted setting the 'placeholder' and 'value' properties to empty strings but have had no success. In the Vuetify documentation, I couldn't find any property that would assign 'admin' to the v-text-field. How can I resolve this issue? Below is my current component code:

<template>
  <v-form>
    <v-container>
      <v-text-field 
        label="E-mail"
        v-model="email"
        >
      </v-text-field>
      <v-text-field
        label="Password"
        v-model="password"
        type="password"
        placeholder=""
        >
      </v-text-field>
      <v-btn 
        color="blue" 
        @click="login()"
      >Submit
      </v-btn>
    </container>
    <pre>
    {{ $data}}
  </pre>
  </form>
</template>

<script>
  import firebase from 'firebase'
  export default {
    data() {
      return {
        email: '',
        password: ''
      }
    },
    methods: {
      login(){
        firebase.auth().signInWithEmailAndPassword(this.email, this.password)
          .then(user => console.log('User connected'), error => console.log(error))
      }
    }
  }
</script>

Answer №1

It seems like the issue you're facing might not be related to your code directly but rather a result of using Chrome. Google's browser can sometimes introduce unexpected behavior that can be hard to control, especially when it comes to handling saved usernames and passwords. In some cases, this can lead to conflicts with styling, such as in Vuetify where labels are used as placeholders. I've personally experienced this with the appearance of saved form dropdowns and noticed a strange font size discrepancy in the username and password fields within v-text-fields until they are clicked on.

Answer №2

After exploring the bug discussion and workaround provided by @185driver, I came across some helpful insights at this link: https://github.com/vuetifyjs/vuetify/issues/3679 However, the suggested code didn't provide a consistent solution for me.

While still in search of a more effective fix, I discovered that setting the labels as active helped alleviate the overlap issue. Although on empty forms, the labels engage prematurely, the overall appearance of the form is improved compared to having text overlap.

login_vue.js

mounted() {
    $("label\[for=\'username\'\]").addClass('v-label--active');
    $("label\[for=\'password\']").addClass('v-label--active');
    ...
}

login.html.erb

<v-row>
  <v-col cols="5"></v-col>
  <v-col cols="2">
    <v-text-field id="username" v-model="email" name="email" label="Username" ></v-text-field>
  </v-col>
</v-row>
    
<v-row>
  <v-col cols="5"></v-col>
  <v-col cols="2">
    <v-text-field id="password" v-model="password" :type="'password'" name="password" label="Password" ></v-text-field>
  </v-col>
</v-row>

Note: It is necessary for the inputs to have unique ids in order for the respective labels to be generated correctly.

https://i.sstatic.net/SKssy.png

Answer №3

Implementing Vue method to manage autofill functionality for email and password fields

mounted() {
  this.detectAutofill();
},

methods: {
  detectAutofill() {
    // Targeting email and password input fields for autofill detection
    const elements = this.$el.querySelectorAll('input[type="email"], input[type="password"]');
    elements.forEach((element) => {
      element.addEventListener('animationstart', (event) => {
        if (event.animationName === 'onAutoFillStart') {
          const label = element.parentElement.querySelector('label');
          // Apply active class to the label if present
          if (label) {
            label.classList.add('v-label--active');
          }
        }
      });
    });
  },
}

Ensure the following CSS rules are included:

@keyframes onAutoFillStart {}
input:-webkit-autofill {
  animation-name: onAutoFillStart;
  animation-duration: 0.01s;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Spinning objects in three.js using tween.js to move around the global axis

Currently, I am working on tween-rotating a 3D cube. Thanks to this helpful post (How to rotate a object on axis world three.js?), I have successfully achieved rotation without any issues. Now, my goal is to transfer the rotation achieved through setFromRo ...

What is the best way to invoke a function from one controller in angularjs to another controller?

I am trying to implement a solution where I need to call the Listing function of testController from userController. I have placed a marker (//) in the code snippet below to indicate where I want to make this function call. This implementation is being d ...

Tips on concealing JavaScript values from being detected during web inspection

I need to securely pass a secret code from my backend to the front end and store it in my JavaScript script. Here is an example of how I want to achieve this: <script> var code = '<%= code %>' </script> Once the us ...

Obtain data with matching JSON values in a REACT application

Recently, I received a JSON file that looks something like this: [ { "symbol": "A", "name": "Agilent Technologies Inc", "exchange": "NYSE", }, { "symbol": "AAC ...

Tips for importing a Multimaterial .dae file in three.js?

I am facing an issue while trying to load a model with multiple materials. I want to access the array of materials but my current approach is not working as expected. loader.load('./dae/tenis.DAE', function ( collada){ dae = collada.scene; ...

The jqGrid is not showing the AJAX JSON data as expected

Currently, I am exploring jqgrid and trying to figure out how to display data in another jqgrid when clicking on a specific colmodel. The retrieved data from the server goes through a function and reaches the grid, but no information is displayed without a ...

What is the most effective way to load data prior to the controller being loaded

Is there a way to fetch data from a service before the view and controller are loaded? I need assistance with this. resolve: { getAlbum: function(albumService){ return albumService.getAlbums(); },getAtum: function(albu ...

What is the most effective method for converting all the keys in a nested array of objects to camel case?

I'm looking to convert all keys of my array of objects into camelCase using TypeScript. Here is the data I have: [ { "Name":"Custom property", "Details":{ "Address":"Huston" ...

Conceal div elements and retain their status when the page is reloaded or switched

I currently have 3 div elements displayed on a webpage: header-div fixed_menu_div page_cont Each of these divs are styled with the following CSS properties: #header-div { top:0; left:0; display:inline; float:left; } #page_cont { mar ...

Tips for removing all elements from an array using jQuery

let values=[]; values.push(data); I have decided to use an array to keep track of my data, and then send it via ajax. The first submission goes smoothly. However, on subsequent submissions, null values are also sent along with the actual data to the serv ...

Having numerous profiles open could lead to ultimately controlling just one - selenium

I'm developing a unique application that empowers users to automate a process across multiple chrome profiles simultaneously. However, I am encountering an issue where the actions performed on each profile are only affecting one. Within my main scrip ...

Why must I handle Access-Control-Allow-Origin issues with XMLHttpRequest() but not with forms?

When attempting to make a request using XMLHttpRequest(), I encounter the Access-Control-Allow-Origin error. However, when I use a form like the one below, no issues arise. Is there something about forms that allows access? What could be the reason for t ...

Share the Angular library distribution folder on a new git repository

I am faced with a dilemma regarding my Angular library that I often use in another project. The way I build my library is by running the command: ng build Upon executing this command, a dist/my-library directory is created at the library root. My goal is ...

Using jsTree to Connect to Objects in a Domain

I'm looking for a way to link each node in my tree with a domain object. Previously, I was passing HTML data and storing the domain object manually using jQuery data: $('li node description').data('obj', my_domain_object); Howeve ...

Uniquely crafted JSON Ajax loop for dynamic transformations

When making an Ajax JSON call to an API, a variable n is used. The higher the value of the variable and depending on the user, more results are fetched. If the API returns nothing, the JSON value response will be "Nothing found". To handle this scenario ...

Obtain the option tag's name

One of my challenges is working with a dynamically created dropdown in HTML and having a dictionary in the back-end to retrieve keys. As users keep adding options to the dropdown, I face the issue of not having a value attribute like this: <option valu ...

What could be causing the network error that keeps occurring when attempting to sign in with Google using React and Firebase?

Having an issue with Google authentication using Firebase. I set up the project on Firebase console and copied the configuration over to my project. Enabled Google sign-in method in the console which was working fine initially. But, after 2 days when I tri ...

What is the best way to transfer my current_user.id to an AngularJS Controller?

Currently, I am retrieving my current_user.id from Ruby on Rails and attempting to transfer it to my angular controller using an HTML hidden input. <input type="hidden" ng-model="user_id" value="<%= current_user.id %>"></input> While de ...

utilize the jQuery method getJSON() for object retrieval

Can anyone help me with my code that looks like the following? <script type="text/javascript"> $(document).ready(function () { var setting = { check: { enable: true }, data: { simpleData: { enable: true } ...

What are the steps to implementing PNG masking using PixiJS?

I am currently working on incorporating a png sprite as a mask for another layer. I found a demo on the pixi.js official website and created this fiddle: https://jsfiddle.net/raphadko/ukc1rwrc/ The code snippet below is what I am using for the masking fu ...