Skip to content

Commit

Permalink
Bug #59697: Add autocomplete JS dependency to blocks integration
Browse files Browse the repository at this point in the history
  • Loading branch information
JerrySmidt committed Jan 29, 2025
1 parent b57584b commit 5814993
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/PostcodeNl/AddressAutocomplete/BlocksIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private function _register_block_frontend_scripts(): void
wp_register_script(
$handle,
Main::$pluginUrl . '/build/' . $name . '-frontend.js',
$scriptAsset['dependencies'],
array_merge($scriptAsset['dependencies'], [Main::AUTOCOMPLETE_LIBRARY_HANDLE]),
$scriptAsset['version'],
true
);
Expand All @@ -63,7 +63,7 @@ private function _register_block_main_integration(): void
wp_register_script(
$handle,
Main::$pluginUrl . '/build/' . $name . '-index.js',
$scriptAsset['dependencies'],
array_merge($scriptAsset['dependencies'], [Main::AUTOCOMPLETE_LIBRARY_HANDLE]),
$scriptAsset['version'],
true
);
Expand Down
11 changes: 7 additions & 4 deletions src/PostcodeNl/AddressAutocomplete/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class Main
/** @var string The version number of the plugin should be equal to the commented version number in ../../../postcode-eu-address-validation.php */
public const VERSION = '2.4.1';

/** @var string Script handle of the autocomplete library. */
public const AUTOCOMPLETE_LIBRARY_HANDLE = 'postcode-eu-autocomplete-address-library';

/** @var string Path to the plugin directory */
public static $pluginDirPath;

Expand Down Expand Up @@ -180,21 +183,21 @@ public function enqueueScripts(): void
{
// CSS
wp_enqueue_style(
'postcode-eu-autocomplete-address-library',
static::AUTOCOMPLETE_LIBRARY_HANDLE,
static::$pluginUrl . '/assets/libraries/postcode-eu-autocomplete-address.css',
[],
static::VERSION
);
wp_enqueue_style(
'postcode-eu-autofill',
static::$pluginUrl . '/assets/css/style.css',
['postcode-eu-autocomplete-address-library'],
[static::AUTOCOMPLETE_LIBRARY_HANDLE],
static::VERSION
);

// Javascript
wp_enqueue_script(
'postcode-eu-autocomplete-address-library',
static::AUTOCOMPLETE_LIBRARY_HANDLE,
static::$pluginUrl . '/assets/libraries/postcode-eu-autocomplete-address.js',
[],
static::VERSION,
Expand All @@ -221,7 +224,7 @@ public function enqueueScripts(): void
'postcode-eu-autofill',
static::$pluginUrl . '/assets/js/postcode-eu-autofill.js',
[
'postcode-eu-autocomplete-address-library',
static::AUTOCOMPLETE_LIBRARY_HANDLE,
'postcode-eu-autocomplete-address-field-mapping',
'postcode-eu-autocomplete-state-mapping',
'wp-i18n',
Expand Down

0 comments on commit 5814993

Please sign in to comment.