The checkbox must be checked for the conditional form to appear, experiencing a Safari bug in version 12.2. No issues found in Chrome and Firefox browsers

My form includes a billing address section with a checkbox that automatically sets the shipping address to match the billing address. If the user unchecks the checkbox, another form will appear below for entering a different shipping address.

The Checkbox

         <div class="col-full">
          <checkbox
            v-model="shippingSameAsBilling"
            :label="$t('billingAddress.shippingSameAsBilling')"
            :disabled="false"
            name="shippingSameAsBilling"
          />
        </div>

Conditional Address Form

      <address-form
        v-if="!shippingSameAsBilling"
        :key="submissionAttempts"
        :address.sync="shippingAddress"
        :address-config="shippingAddressConfig"
        :countries="countriesAllowedForShipping"
        name="shippingAddress"
        data-test="shipping-address"
        @updateCountryCode="updateCountryCode"
      />

State Property

data() {
  return {
    shippingSameAsBilling: true
  }
 }

While everything functions correctly in Chrome and Firefox, there is an issue with Safari 12.2 where the form does not render when the checkbox is unchecked. I am currently using the Safari web inspector but have been unable to identify the cause of this problem.

<template>
  <div
    :data-test="name"
    :class="{ 'checkbox--disabled': disabled }"
    class="checkbox">
    <input
      ref="checkbox"
      :id="name"
      :value="true"
      :name="name"
      :checked="value"
      :disabled="disabled"
      class="checkbox__input"
      type="checkbox"
      @input="input()">
    <label
      :for="name"
      class="checkbox__label"
      tabindex="0"
      @keyup.space="toggle($event)">
      <div>
        <div>{{ label }}</div>
        <div
          v-if="subtext"
          class="checkbox__subtext">
          {{ subtext }}
        </div>
      </div>
    </label>
  </div>
</template>

<script>
export default {
  name: 'Checkbox',
  props: {
    /**
     * Disabled or not
     */
    disabled: {
      type: Boolean,
      default: false
    },
    /**
     * The label in front of the checkbox
     */
    label: {
      type: String,
      required: true
    },
    /**
     * The name of the element, used for testing and automation
     */
    name: {
      type: String,
      required: true
    },
    /**
     * Subtext rendered under the label
     */
    subtext: {
      type: String,
      default: ''
    },
    /**
     * The bound model object
     * @model
     */
    value: {
      type: Boolean,
      required: true
    }
  },
  methods: {
    input () {
      /**
       * Input event on change
       *
       * @event input
       * @type {Boolean}
       */
      this.$emit('input', this.$refs.checkbox.checked)
    },
    toggle () {
      const { checkbox } = this.$refs

      if (!this.disabled) {
        checkbox.checked = !checkbox.checked
      }
    }
  }
}
</script>

Answer №1

Transform this:

@input="input()"

into this:

@change="input"

Safari lacks an input event for the HTML Checkbox element

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

Handling multiple patch requests using React and Redux when onBlur event occurs

Currently, I am using Redux-form for editing guest information. Whenever a field is left, the content of that field gets patched to the guest through a simple patch request and the store is updated accordingly. However, an issue arises when I use Google fo ...

JavaScript fails to function properly on FireFox

I'm currently troubleshooting a script that works in Chrome but not in FireFox. I suspect it's due to the webkit syntax, so I tried converting it to a standard gradient without success. Can you help me identify what's causing the issue? Web ...

conceal parent window element upon clicking an image within an iframe

I'm facing a challenge with hiding certain buttons in a parent window when opening a modal by clicking an image inside an iframe. Below is the code snippet that I am using: In the parent window - <iframe id="gallery" src="links/gallery.html" wid ...

Ways to generate an Angular 7 component

Seeking guidance on creating an angular 7 component. I have forked a jsFiddle at this link: https://jsfiddle.net/gauravshrestha/fdxsywLv/. The chart in the fiddle allows data points to be dragged up and down. My goal is to convert this into a component whe ...

What is the best way to utilize AJAX for retrieving numerous data sets from a PHP file?

Currently, I am tackling a project that involves an HTML file containing two different divs: one for "product" and the other for "price". These divs need to display text from rows in a database, which can be accessed easily using a PHP file. Using AJAX, I ...

Demonstrating reactivity: updating an array property based on a window event

One example scenario involves setting specific elements to have an active class by assigning the property "active" as true (using v-bind:class). This property is modified within a foreach loop, after certain conditions are met, through the method "handleSc ...

Experiencing problems with CSS compatibility while transitioning from vanilla JavaScript to React

Currently, I am working on revamping the frontend of an app that was initially built with vanilla javascript and transitioning it to a React framework. However, I'm encountering some challenges with styling the HTML elements. Specifically, the textare ...

Steps for ensuring a div component appears on top of any other component (like h1 or p)

The outcome of the code below is displayed in this image: https://i.stack.imgur.com/CPDqC.png Is it possible to make the dropdown overlap on top of the 'HELLO's text, hiding the h1 and p tags? I have tried using z-index without success. Making ...

Can you explain the purpose of the "letter:" included in the code and how it is utilized?

g: function testFunction() { return true; } h: function anotherTestFunction() { } i: console.log('test') I'm intrigued by the mystery of this code snippet. As is written, I am executing it in NodeJS version 16 or higher and trying to un ...

An issue with the image filter function in JavaScript

I am currently working on a simple application that applies image filters to images. Below is the code I have written for this purpose. class ImageUtil { static getCanvas(width, height) { var canvas = document.querySelector("canvas"); canvas.widt ...

Encountering an issue in Laravel 8 JetStream: Mix file '/css/app.css' cannot be found when running npm run prod

I have a Laravel 8 application set up with Jetstream, Inertia Js, and VueJs 3. When I execute: npm run prod An error occurs: Exception Unable to find Mix file: /css/app.css. (View: /var/www/html/mysite/resources/views/app.blade.php) http://subdomain.mysi ...

Executing functions in a pre-defined order with AngularJS: A step-by-step guide

In my AngularJS Controller, I have a receiver set up like this: // Broadcast Receiver $rootScope.$on('setPlayListEvent', function(event, playListData) { if($scope.someSoundsArePlaying === true) { $scope.stopAllS ...

Initiate automatic playback of audio on website following a delay

I attempted to change the state of play from false to true and also experimented with adding ComponentDidMount,ComponentDidUpdate, and ComponentWillMount but unfortunately, nothing seemed to solve the issue. I consistently encountered errors at different p ...

Can TypeScript be used to dynamically render elements with props?

After extensive research on SO and the wider web, I'm struggling to find a solution. I have devised two components, Link and Button. In short, these act as wrappers for <a> and <button> elements with additional features like chevrons on t ...

Tips for transferring information between two distinct pages utilizing the jQuery POST technique

I'm dealing with two PHP files called card_process.php and payment.php. My goal is to transfer data from the cart_process page to the payment page. Here's a snippet of the code: In cart_process.php: $paynow = "<button type='submit' ...

Upon calling the method, an undesirable page refresh occurs

I have been experimenting with dynamically generating additional input fields using vuejs when a user clicks a button. Initially, my code functions properly by creating more fields, but unexpectedly the page refreshes automatically, resetting the user&apos ...

PHP cannot be utilized within the script tag

I'm currently using JavaScript to display an error message If a user inputs incorrect information and I add the following code: <?php $_POST["usernamereg"] ?> = usernamereg; the alert function stops working. However, if I remove this code, t ...

Refresh the screen after 10 seconds

Apologies if I'm not explaining this well in advance. I am looking to create a dynamic webpage using JavaScript that automatically updates every 10 seconds. Does anyone have an example code snippet for this? **Specifically, allow ...

What is the best way to add animation to my `<div>` elements when my website is first loaded?

I am looking for a way to enhance the appearance of my <div> contents when my website loads. They should gradually appear one after the other as the website loads. Additionally, the background image should load slowly due to being filtered by the wea ...

I am facing an issue with submitting a form using jQuery POST and php serialization

I am struggling to send form data using jQuery. The data seems to be stuck in a loop where it keeps requesting the page ./?page=game&mode=search&type=private with the GET function and does not reach the server. Can someone help me identify what I m ...