Skip to content

Grid Pro checkboxes can't be clicked on Safari #6756

Closed

Description

@tomivirkki

Description

The built-in editor for boolean values (checkbox) can't be toggled by mouse-clicking on Safari. It can be toggled with keyboard, however.

Kapture.2023-11-07.at.14.09.19.mp4

Expected outcome

The checkbox should toggle with mouse-click

Minimal reproducible example

https://vaadin.com/docs/latest/components/grid-pro#recommended-built-in-editors

Steps to reproduce

  1. Open https://vaadin.com/docs/latest/components/grid-pro#recommended-built-in-editors with Safari
  2. Enter edit mode on the "Subscriber" column
  3. Try to toggle the checkbox with mouse-click

Environment

Vaadin version(s): 24
OS: MacOS Sonoma 14

Browsers

Safari

Activity

  1. web-padawan commented on Nov 7, 2023

    @web-padawan
    Member

    Looks like there is a focusout event fired on mousedown when attempting to click vaadin-checkbox in Safari.
    This does not happen in Chrome and Firefox. We might want to use event.preventDefault() as a workaround.

  2. vursen commented on Nov 8, 2023

    @vursen
    Contributor

    Just for the record, the checkbox works fine on my iPhone (iOS 17.0.3).

  3. self-assigned this
    on Nov 9, 2023
  4. vursen commented on Nov 9, 2023

    @vursen
    Contributor

    The issue can be observed with the pure checkbox component:

    <vaadin-checkbox>Checkbox</vaadin-checkbox>
    
    <script type="module">
    import '@vaadin/checkbox';
    
    const checkbox = document.querySelector('vaadin-checkbox');
    checkbox.addEventListener('focusout', (event) => {
      console.log(event);
    });
    </script>
    1. Click on the checkbox to select it
    2. Click on the checkbox to deselect it
    3. Observe a focusout on the second click in Safari, but no focusout in Chrome.

    At the same time, it's not reproducible with the native checkbox, which makes me suspect it has to do with CSS or Shadow DOM.

  5. DiegoCardoso commented on Nov 10, 2023

    @DiegoCardoso
    Contributor

    Just to mention that the same Grid Pro example in V14 works in Safari

  6. vursen commented on Nov 13, 2023

    @vursen
    Contributor

    I just noticed that there is a workaround in checkbox which has been specifically introduced to make focus work in Safari:

    // Clicking the checkbox or radio-button in Safari
    // does not make it focused, so we do it manually.
    if (!isElementFocused(input)) {
    input.focus();
    }

    It's apparently no longer enough. It successfully sets focus when you click on a checkbox that doesn't have focus yet. But, when you click on a checkbox that already has focus, what happens is that Safari first removes focus – which results in a focusout – and then the workaround returns focus back on the checkbox. However, that focusout becomes enough for grid-pro to close the editor.

  7. vursen commented on Nov 13, 2023

    @vursen
    Contributor

    It seems adding a [tabindex=0] to the input element fixes the issue. Note, the version 14 also sets this attribute by default. Also, it makes the above workaround unnecessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions