Plugin Directory

Changeset 3365959


Ignore:
Timestamp:
09/22/2025 04:52:53 PM (6 months ago)
Author:
printess
Message:

Fixed bug that saved a wrong variant in case the current user is not logged in and clicks on save. Before, the default variant was used instead of the current selected variant.

Location:
printess-editor/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • printess-editor/trunk/includes/js/printessWoocommerce.js

    r3364022 r3365959  
    1 function trapFocus(root) {
     1const printessFocusListeners = [];
     2const printessTrapFocus = function (root) {
    23    const keyboardFocusableElements = root?.querySelectorAll('a[href], button, input, textarea, select, details, [tabindex]');
    34    if (keyboardFocusableElements && keyboardFocusableElements.length > 0) {
    45        const lastFocusableElement = keyboardFocusableElements[keyboardFocusableElements.length - 1];
    56        const firstFocusableElement = keyboardFocusableElements[0];
    6         firstFocusableElement?.addEventListener("keydown", (e) => {
    7             if (e.key === "Tab" && e.shiftKey && lastFocusableElement) {
    8                 e.preventDefault();
     7        const tabBackToLast = (keyEvent) => {
     8            if (keyEvent.key === "Tab" && keyEvent.shiftKey && lastFocusableElement) {
     9                keyEvent.preventDefault();
    910                lastFocusableElement.focus();
    1011            }
    11         });
    12         lastFocusableElement?.addEventListener("keydown", (e) => {
    13             if (e.key === "Tab" && !e.shiftKey && firstFocusableElement) {
    14                 e.preventDefault();
     12        };
     13        const tabToFirst = (keyEvent) => {
     14            if (keyEvent.key === "Tab" && !keyEvent.shiftKey && firstFocusableElement) {
     15                keyEvent.preventDefault();
    1516                firstFocusableElement.focus();
    1617            }
    17         });
     18        };
     19        printessFocusListeners.push(new AbortController);
     20        firstFocusableElement?.addEventListener("keydown", tabBackToLast, { signal: printessFocusListeners[printessFocusListeners.length - 1].signal });
     21        lastFocusableElement?.addEventListener("keydown", tabToFirst, { signal: printessFocusListeners[printessFocusListeners.length - 1].signal });
    1822        firstFocusableElement?.focus();
    1923    }
    20 }
     24};
     25const printessFreeFocus = function () {
     26    if (printessFocusListeners.length > 0) {
     27        printessFocusListeners[printessFocusListeners.length - 1].abort();
     28        printessFocusListeners.pop();
     29    }
     30};
    2131const initPrintessWCEditor = function (printessSettings) {
    2232    const CART_FORM_SELECTOR = "form.cart";
     
    174184        if (dialog) {
    175185            dialog.classList.remove("visible");
     186            printessFreeFocus();
    176187        }
    177188    };
     
    292303            cancelButton.addEventListener("click", internalCancelCallback);
    293304        }
    294         cancelButton.style.backgroundColor = "red";
    295         trapFocus(dialog);
     305        printessTrapFocus(dialog);
    296306    };
    297307    const postMessage = (cmd, properties) => {
     
    319329            }
    320330        }
    321         trapFocus(overlay);
     331        printessTrapFocus(overlay);
    322332    };
    323333    const hideInformationOverlay = () => {
     
    325335        if (overlay) {
    326336            overlay.classList.remove("visible");
     337            printessFreeFocus();
    327338        }
    328339    };
     
    934945                };
    935946                const loginCallback = (designName) => {
    936                     if (!loginAndSave(designName, settings.product.id, variant ? variant.id : null, saveToken, thumbnailUrl, productValues)) {
     947                    if (!loginAndSave(designName, settings.product.id, variant ? variant.id : null, saveToken, thumbnailUrl, getCurrentProductOptionValues(settings.product, false))) {
    937948                        alert(printessSettings.userMessages && printessSettings.userMessages["noDisplayName"] ? printessSettings.userMessages["noDisplayName"] : 'Please provide a display name.');
    938949                        showSaveDialog(designName, printessSettings.userIsLoggedIn ? saveDesignCallback : loginCallback, cancelCallback);
     
    12881299            dlg.removeEventListener("keyup", keyUpHandler);
    12891300            dlg.removeEventListener("keydown", keyDownHandler);
     1301            printessFreeFocus();
    12901302        }
    12911303        if (previouslyFocused && previouslyFocused instanceof HTMLElement) {
     
    13231335        dlg.addEventListener("keydown", keyDownHandler);
    13241336    }
    1325     trapFocus(dlg);
     1337    printessTrapFocus(dlg);
    13261338}
    13271339function printessRegisterCheckoutFilters(registerCheckoutFilters) {
  • printess-editor/trunk/printess.php

    r3364556 r3365959  
    55 * Plugin URI: https://printess.com/kb/integrations/woo-commerce/index.html
    66 * Developer: Bastian Kröger (support@printess.com); Alexander Oser (support@printess.com)
    7  * Version: 1.6.64
     7 * Version: 1.6.65
    88 * Author: Printess
    99 * Author URI: https://printess.com
     
    1414 * Tested up to: 6.8
    1515 *
    16  * Woo: 10000:924022dfsfhsf8429842386wdff234sfd
     16 * Woo: 10000:924023dfsfhsf8429842386wdff234sfd
    1717 * WC requires at least: 5.8
    1818 * WC tested up to: 9.8.2
     
    32903290        $token         = printess_get_value_from_array( $_GET, 'token' );
    32913291        $display_name  = printess_get_value_from_array( $_GET, 'displayName' );
     3292        $options  = printess_get_value_from_array( $_GET, 'options' );
    32923293        $user_id       = null;
    32933294
  • printess-editor/trunk/readme.txt

    r3364556 r3365959  
    338338= 1.6.64 =
    339339- Fixed improper handling of cart item sorting for some users that have cart items that are not printess cart items and have object type cart items instead of array type cart items
     340
     341= 1.6.65 =
     342- Fixed: Fixed bug that saved a wrong variant in case the current user is not logged in and clicks on save. Before, the default variant was used instead of the current selected variant.
Note: See TracChangeset for help on using the changeset viewer.