The removal of the Button class does not result in immediate rendering

I built a Vue application that displays a button on the screen using Bulma for styling. Upon page load, the button is correctly styled with solid red color and white text since the "is-outlined" class is not present. However, when I click the button, it should add the "is-outlined" class to render red text and border on a white background. Here's what happens upon clicking the button:

  1. The displayed data disappears as intended (indicating that the click event functions properly while the rest of the page remains functional).
  2. Upon inspecting in Chrome's developer tools, I see the immediate addition of the is-outlined class to the button's CSS, as expected.
  3. However, the button does not visually switch to an outlined style immediately after clicking.

Interestingly, as soon as I shift focus away from the button by clicking elsewhere on the screen or opening a different window, the CSS rendering occurs, and the button updates to reflect the added class. This automatic change happens regardless of where I click, prompting the button to display according to the recently added class.

Furthermore, if I click the button again, triggering the removal of the class, the button instantly reverts back to its original state with white text on a red background without requiring a click outside the button.

So, my question arises regarding the disparity in rendering behavior between adding a class (delayed response) and removing a class (instantaneous response).

Here is the updated full component code (still learning Vue, so it may not be optimal):

<template>
<!-- Component template code here -->
</template>

<script>
// JavaScript logic for the Vue component
export default {
    // Component properties, methods, data, etc.
}
</script>

<style>
/* Component-specific styles defined here */
</style>

Any guidance on this matter would be highly appreciated!

Answer №1

Ensure to utilize @click.stop for halting propagation, as failing to do so will result in capturing all click events

Answer №2

After some investigation, I identified the issue and was able to find a solution. It turns out that the button was not changing to an outlined style until I moved away from it because it was still in a "focused" state, causing the focused style to be displayed. This behavior was specific to Chrome and can be better explained as follows:

"Rather than being active, the button was actually focused due to the :focus pseudo-class styling. It appears that in Chrome, buttons remain focused after they are clicked, unlike in other browsers."

https://github.com/jgthms/bulma/issues/482

To resolve this issue, I made the decision to convert the buttons into anchors and apply the button style. It seems that links and buttons are handled differently by Chrome.

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

Is it achievable to create shadows that do not overlap?

When you hover your mouse over the pill-shaped object, it should smoothly move over the circle as desired. However, the shadow of the circle still remains visible creating an unwanted effect. I am looking for a solution where the shadows do not overlap but ...

Uncover the hidden treasures within JSON string information

I am working with a JSON feed that contains String data type. "[ { "str": "<ul><li>Item1<li><li>Item2<li><li>Item3<li><ul>" } ][ { "str": "<ul><li>Teacher Account< ...

Tips on updating a specific value within an element stored in an array

I'm currently in the process of setting up a table where each row contains unique values. Using a for loop, I am able to generate these rows and store them in an array. Now, my question arises when I consider modifying a particular value with the id " ...

The function inArray() in jQuery will return a value of -1 when an array consists of

When using jQuery inArray, if the array contains only one element, it will return -1. var a = Array(1); console.log($.inArray(1,a)); This result is -1. However, if the array has 2 or more elements, it functions correctly. var a = Array(1,2,3); console.l ...

Issue with angular directive scope not binding correctly

Good day I'm relatively new to Angular and directives, but I'm facing an issue with the scope (in my specific case). I have defined the directive as follows: angular.module('ToolBarMod', ['ngAria']) .controller('ToolBar ...

Error: The requested resource does not have the 'Access-Control-Allow-Origin' header. The request is successful, but an error is being triggered

As I am trying to make an Ajax cross domain request, I have come across a strange issue. In the console of Chrome dev tools, I see the following error: "No 'Access-Control-Allow-Origin' header is present on the requested resource" Despite this ...

Exploring the Mathematical Capabilities of jQuery

I have a question regarding a jQuery code that retrieves the price of Bitcoin from a JSON API and displays its current value in euros. I am interested in converting this to another currency, such as Danish Crown or any other. Essentially, my query is whe ...

Retrieving information from React elements

Recently, I ventured into the world of React and started building a mock website for online food ordering. One of my components is called Items, which utilizes props to display all the food items on the webpage. import { useState } from "react"; ...

JavaScript drag functionality is jerky on iPads, not seamless

I am currently attempting to implement a feature where I can drag a div (#drag) within its parent container (#container) using only pure JavaScript. This functionality is specifically required to work on iPad devices only. After writing a script that func ...

Avoiding Memory Leaks and Managing JS Heap Size While Polling Large Amounts of Data Every 5 Seconds with Vuex

I'm currently working on a Vue application that utilizes Vuex for state management. Within this application, I have several store modules set up at the root level. Periodically, every 5 seconds, I retrieve a large amount of data and update the store s ...

Show buttons in varying styles aligned next to each other

Here is the code snippet I'm currently working with: <fieldset class=last> <button>Refresh</button> <button> Clear</button> </fieldset> <form method="POST" action="*******"> <button> Down ...

Send form information using AJAX response

I have successfully implemented a feature where I load an iframe into a div with the id of #output using AJAX. This allows me to play videos on my website. jQuery( document ).ready( function( $ ) { $( '.play_next' ).on('click', fun ...

Combine consecutive <p> tags within a <div> container

Can you group all adjacent <p> elements together within a <div> element? For example, assuming the following structure: <div class="content"> <p>one</p> <p>two</p> <h2> not p</h2> <p>thr ...

Steps for passing $scope to an AngularJS 1.5 component or directive

Exploring the utilization of the new .component() method in angular 1.5 has been a challenge. There is limited information available on its usage, and even the angular documentation does not provide clear guidance. Attempting to pass the scope or an objec ...

Customizing checkboxes in React with JSS: A step-by-step guide

I'm currently working on customizing CSS using JSS as my styling solution, which is proving to be a bit complex while following the w3schools tutorial. https://www.w3schools.com/howto/howto_css_custom_checkbox.asp HTML: <label class="container"& ...

I'm looking to incorporate a hover effect on a hyperlink within JEditorPane utilizing Swing in Java. How can I achieve this

After successfully implementing the hyperlink in jEditorPane through this link, I now aim to incorporate a hover effect to the hyperlink. I attempted to apply CSS using the following code: MyHTMLEditorKit kit = new MyHTMLEditorKit(); setEditorKitForConten ...

Value-based JavaScript object prototype

Is there a way to ensure that every new object I create has its own unique dataTransfer property? For instance, when I try something like Object.prototype.dataTransfer = new DataTransfer();, I want a.dataTransfer.prop to remain 1 even if b.dataTransfer.pro ...

Variations in how words are organized within a sentence

Can you help me devise an algorithm to identify all possible combinations of word groupings in a sentence without changing the order of the words? For example, for the sentence "the test case phrase," the various combinations would include: ['the te ...

Ways to access component load status in Next.js

I'm currently developing a basic Pokedex to showcase all Pokemon. I am utilizing a map function on an array of Pokemon objects to display all the cards in this manner: {pokemons.results.map((el, i) => { return ( <di ...

Viewing all album titles simultaneously using the Flickr API

After trying a different approach due to lack of responses to my previous question, I am still facing the same issue. My code successfully retrieves all album names and corresponding photos from Flickr API, but it displays all album names at once followed ...