Skip to content

Commit 8326e49

Browse files
authored
Merge pull request #2817 from RabbiIslamRony/fix-order-click
fix order click
2 parents 27fe6ee + 8693ceb commit 8326e49

7 files changed

Lines changed: 99 additions & 37 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-primitives', 'wp-url', 'wp-viewport'), 'version' => 'af46d10149e02f3af190');
1+
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-primitives', 'wp-url', 'wp-viewport'), 'version' => '768b4e5afa2349cb8ef7');

assets/build/js/react/admin/order.js

Lines changed: 64 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -34197,21 +34197,23 @@ __webpack_require__.r(__webpack_exports__);
3419734197
/* harmony import */ var _babel_runtime_helpers_taggedTemplateLiteral__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @babel/runtime/helpers/taggedTemplateLiteral */ "./node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteral.js");
3419834198
/* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/hooks */ "@wordpress/hooks");
3419934199
/* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_3__);
34200-
/* harmony import */ var _shamim_ahmed_dashboard__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @shamim-ahmed/dashboard */ "./node_modules/.pnpm/@shamim-ahmed+dashboard@0.0_f9e83b98cca10eeaa069d2ca0d26c52a/node_modules/@shamim-ahmed/dashboard/build/dashboard.es.js");
34201-
/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! styled-components */ "./node_modules/.pnpm/styled-components@6.3.12_react@18.3.1/node_modules/styled-components/dist/styled-components.browser.esm.js");
34202-
/* harmony import */ var _controls_custom_field_validation_FieldValidator__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../controls/custom-field/validation/FieldValidator */ "./assets/src/js/react/admin/controls/custom-field/validation/FieldValidator.ts");
34203-
/* harmony import */ var _controls_custom_field_validation_validators_EmailValidator__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/custom-field/validation/validators/EmailValidator */ "./assets/src/js/react/admin/controls/custom-field/validation/validators/EmailValidator.ts");
34204-
/* harmony import */ var _controls_custom_field_validation_validators_MaxLengthValidator__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../controls/custom-field/validation/validators/MaxLengthValidator */ "./assets/src/js/react/admin/controls/custom-field/validation/validators/MaxLengthValidator.ts");
34205-
/* harmony import */ var _controls_custom_field_validation_validators_MinLengthValidator__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../controls/custom-field/validation/validators/MinLengthValidator */ "./assets/src/js/react/admin/controls/custom-field/validation/validators/MinLengthValidator.ts");
34206-
/* harmony import */ var _controls_custom_field_validation_validators_NumberValidator__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../controls/custom-field/validation/validators/NumberValidator */ "./assets/src/js/react/admin/controls/custom-field/validation/validators/NumberValidator.ts");
34207-
/* harmony import */ var _controls_custom_field_validation_validators_RequiredValidator__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../controls/custom-field/validation/validators/RequiredValidator */ "./assets/src/js/react/admin/controls/custom-field/validation/validators/RequiredValidator.ts");
34208-
/* harmony import */ var _icons_CommentIcon__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../icons/CommentIcon */ "./assets/src/js/react/admin/icons/CommentIcon.tsx");
34209-
/* harmony import */ var _icons_DocIcon__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../icons/DocIcon */ "./assets/src/js/react/admin/icons/DocIcon.tsx");
34210-
/* harmony import */ var _icons_QuestionCircleIcon__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../icons/QuestionCircleIcon */ "./assets/src/js/react/admin/icons/QuestionCircleIcon.tsx");
34211-
/* harmony import */ var _orders__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./orders */ "./assets/src/js/react/admin/pages/orders/index.tsx");
34212-
/* harmony import */ var _orders_edit__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./orders/edit */ "./assets/src/js/react/admin/pages/orders/edit/index.tsx");
34213-
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! react/jsx-runtime */ "react/jsx-runtime");
34214-
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_17___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_17__);
34200+
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element");
34201+
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_4__);
34202+
/* harmony import */ var _shamim_ahmed_dashboard__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @shamim-ahmed/dashboard */ "./node_modules/.pnpm/@shamim-ahmed+dashboard@0.0_f9e83b98cca10eeaa069d2ca0d26c52a/node_modules/@shamim-ahmed/dashboard/build/dashboard.es.js");
34203+
/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! styled-components */ "./node_modules/.pnpm/styled-components@6.3.12_react@18.3.1/node_modules/styled-components/dist/styled-components.browser.esm.js");
34204+
/* harmony import */ var _controls_custom_field_validation_FieldValidator__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/custom-field/validation/FieldValidator */ "./assets/src/js/react/admin/controls/custom-field/validation/FieldValidator.ts");
34205+
/* harmony import */ var _controls_custom_field_validation_validators_EmailValidator__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../controls/custom-field/validation/validators/EmailValidator */ "./assets/src/js/react/admin/controls/custom-field/validation/validators/EmailValidator.ts");
34206+
/* harmony import */ var _controls_custom_field_validation_validators_MaxLengthValidator__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../controls/custom-field/validation/validators/MaxLengthValidator */ "./assets/src/js/react/admin/controls/custom-field/validation/validators/MaxLengthValidator.ts");
34207+
/* harmony import */ var _controls_custom_field_validation_validators_MinLengthValidator__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../controls/custom-field/validation/validators/MinLengthValidator */ "./assets/src/js/react/admin/controls/custom-field/validation/validators/MinLengthValidator.ts");
34208+
/* harmony import */ var _controls_custom_field_validation_validators_NumberValidator__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../controls/custom-field/validation/validators/NumberValidator */ "./assets/src/js/react/admin/controls/custom-field/validation/validators/NumberValidator.ts");
34209+
/* harmony import */ var _controls_custom_field_validation_validators_RequiredValidator__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../controls/custom-field/validation/validators/RequiredValidator */ "./assets/src/js/react/admin/controls/custom-field/validation/validators/RequiredValidator.ts");
34210+
/* harmony import */ var _icons_CommentIcon__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../icons/CommentIcon */ "./assets/src/js/react/admin/icons/CommentIcon.tsx");
34211+
/* harmony import */ var _icons_DocIcon__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../icons/DocIcon */ "./assets/src/js/react/admin/icons/DocIcon.tsx");
34212+
/* harmony import */ var _icons_QuestionCircleIcon__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../icons/QuestionCircleIcon */ "./assets/src/js/react/admin/icons/QuestionCircleIcon.tsx");
34213+
/* harmony import */ var _orders__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./orders */ "./assets/src/js/react/admin/pages/orders/index.tsx");
34214+
/* harmony import */ var _orders_edit__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./orders/edit */ "./assets/src/js/react/admin/pages/orders/edit/index.tsx");
34215+
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! react/jsx-runtime */ "react/jsx-runtime");
34216+
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_18___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_18__);
3421534217

3421634218

3421734219

@@ -34233,23 +34235,29 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
3423334235

3423434236

3423534237

34238+
34239+
// Stable reference — avoids recreating the array on every render which would
34240+
// cause useActiveAdminMenu's useLayoutEffect to re-run and re-attach its
34241+
// preventDefault handler, overwriting our click override below.
34242+
34243+
var ROOT_PATHS = [];
3423634244
var actionItems = {
3423734245
documentation: {
3423834246
label: 'Docs',
3423934247
path: 'https://directorist.com/documentation/',
34240-
icon: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_17__.jsx)(_icons_DocIcon__WEBPACK_IMPORTED_MODULE_13__["default"], {})
34248+
icon: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_18__.jsx)(_icons_DocIcon__WEBPACK_IMPORTED_MODULE_14__["default"], {})
3424134249
},
3424234250
support: {
3424334251
label: 'Help & Support',
3424434252
path: 'https://directorist.com/dashboard/#support',
34245-
icon: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_17__.jsx)(_icons_QuestionCircleIcon__WEBPACK_IMPORTED_MODULE_14__["default"], {})
34253+
icon: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_18__.jsx)(_icons_QuestionCircleIcon__WEBPACK_IMPORTED_MODULE_15__["default"], {})
3424634254
},
3424734255
feedback: {
3424834256
path: 'https://directorist.com/dashboard/#feedback',
34249-
icon: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_17__.jsx)(_icons_CommentIcon__WEBPACK_IMPORTED_MODULE_12__["default"], {})
34257+
icon: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_18__.jsx)(_icons_CommentIcon__WEBPACK_IMPORTED_MODULE_13__["default"], {})
3425034258
}
3425134259
};
34252-
var ThemeWrapper = styled_components__WEBPACK_IMPORTED_MODULE_5__["default"].div(_templateObject || (_templateObject = (0,_babel_runtime_helpers_taggedTemplateLiteral__WEBPACK_IMPORTED_MODULE_2__["default"])(["\n\t--color-light: #e7ecee;\n"])));
34260+
var ThemeWrapper = styled_components__WEBPACK_IMPORTED_MODULE_6__["default"].div(_templateObject || (_templateObject = (0,_babel_runtime_helpers_taggedTemplateLiteral__WEBPACK_IMPORTED_MODULE_2__["default"])(["\n\t--color-light: #e7ecee;\n"])));
3425334261
function App() {
3425434262
// const fieldValidation = ({
3425534263
// value,
@@ -34292,7 +34300,7 @@ function App() {
3429234300
errors = _ref.errors,
3429334301
setErrors = _ref.setErrors;
3429434302
if (!(field !== null && field !== void 0 && field.validation)) return;
34295-
var validatorContext = new _controls_custom_field_validation_FieldValidator__WEBPACK_IMPORTED_MODULE_6__.FieldValidator();
34303+
var validatorContext = new _controls_custom_field_validation_FieldValidator__WEBPACK_IMPORTED_MODULE_7__.FieldValidator();
3429634304
var errorResult = null;
3429734305
if (field.validation.condition && !field.validation.condition(attributes)) {
3429834306
errorResult = {
@@ -34306,19 +34314,19 @@ function App() {
3430634314
ruleValue = _ref3[1];
3430734315
switch (rule) {
3430834316
case 'required':
34309-
validatorContext.addValidator(new _controls_custom_field_validation_validators_RequiredValidator__WEBPACK_IMPORTED_MODULE_11__.RequiredValidator());
34317+
validatorContext.addValidator(new _controls_custom_field_validation_validators_RequiredValidator__WEBPACK_IMPORTED_MODULE_12__.RequiredValidator());
3431034318
break;
3431134319
case 'email':
34312-
validatorContext.addValidator(new _controls_custom_field_validation_validators_EmailValidator__WEBPACK_IMPORTED_MODULE_7__.EmailValidator());
34320+
validatorContext.addValidator(new _controls_custom_field_validation_validators_EmailValidator__WEBPACK_IMPORTED_MODULE_8__.EmailValidator());
3431334321
break;
3431434322
case 'min_length':
34315-
validatorContext.addValidator(new _controls_custom_field_validation_validators_MinLengthValidator__WEBPACK_IMPORTED_MODULE_9__.MinLengthValidator(ruleValue));
34323+
validatorContext.addValidator(new _controls_custom_field_validation_validators_MinLengthValidator__WEBPACK_IMPORTED_MODULE_10__.MinLengthValidator(ruleValue));
3431634324
break;
3431734325
case 'max_length':
34318-
validatorContext.addValidator(new _controls_custom_field_validation_validators_MaxLengthValidator__WEBPACK_IMPORTED_MODULE_8__.MaxLengthValidator(ruleValue));
34326+
validatorContext.addValidator(new _controls_custom_field_validation_validators_MaxLengthValidator__WEBPACK_IMPORTED_MODULE_9__.MaxLengthValidator(ruleValue));
3431934327
break;
3432034328
case 'number':
34321-
validatorContext.addValidator(new _controls_custom_field_validation_validators_NumberValidator__WEBPACK_IMPORTED_MODULE_10__.NumberValidator());
34329+
validatorContext.addValidator(new _controls_custom_field_validation_validators_NumberValidator__WEBPACK_IMPORTED_MODULE_11__.NumberValidator());
3432234330
break;
3432334331
}
3432434332
});
@@ -34333,26 +34341,51 @@ function App() {
3433334341
};
3433434342
(0,_wordpress_hooks__WEBPACK_IMPORTED_MODULE_3__.addAction)('wpmvc-field-on-blur', 'directorist-form-validation', fieldValidation);
3433534343
(0,_wordpress_hooks__WEBPACK_IMPORTED_MODULE_3__.addAction)('wpmvc-field-on-change', 'directorist-form-validation', fieldValidation);
34344+
34345+
// Bug fix: useActiveAdminMenu (in @wpmvc/admin-sidebar) intercepts the
34346+
// .wp-first-item ("All Listings") click with e.preventDefault() and tries
34347+
// React Router navigation. Since rootPaths=[] there is no valid route to
34348+
// navigate to, so the link silently does nothing.
34349+
// We re-bind the click handler after the Dashboard's useLayoutEffect runs
34350+
// (setTimeout 0 defers to the next macrotask) so it always does a full
34351+
// WordPress page navigation instead.
34352+
(0,_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.useEffect)(function () {
34353+
var timer = setTimeout(function () {
34354+
var $ = window.jQuery;
34355+
if (!$) return;
34356+
var $firstItem = $('#menu-posts-at_biz_dir').find('a.wp-first-item');
34357+
var href = $firstItem.attr('href');
34358+
if (href) {
34359+
$firstItem.off('click').on('click', function (e) {
34360+
e.preventDefault();
34361+
window.location.href = href;
34362+
});
34363+
}
34364+
}, 0);
34365+
return function () {
34366+
return clearTimeout(timer);
34367+
};
34368+
}, []);
3433634369
var routes = [{
3433734370
path: '/',
34338-
element: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_17__.jsx)(_orders__WEBPACK_IMPORTED_MODULE_15__["default"], {}),
34371+
element: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_18__.jsx)(_orders__WEBPACK_IMPORTED_MODULE_16__["default"], {}),
3433934372
index: true
3434034373
}, {
3434134374
path: '/edit/:id',
3434234375
// element: <Edit />,
34343-
element: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_17__.jsx)(_orders_edit__WEBPACK_IMPORTED_MODULE_16__["default"], {})
34376+
element: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_18__.jsx)(_orders_edit__WEBPACK_IMPORTED_MODULE_17__["default"], {})
3434434377
}];
34345-
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_17__.jsx)(ThemeWrapper, {
34346-
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_17__.jsx)(_shamim_ahmed_dashboard__WEBPACK_IMPORTED_MODULE_4__.Dashboard, {
34378+
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_18__.jsx)(ThemeWrapper, {
34379+
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_18__.jsx)(_shamim_ahmed_dashboard__WEBPACK_IMPORTED_MODULE_5__.Dashboard, {
3434734380
pageTopLevelID: "#menu-posts-at_biz_dir",
34348-
rootPaths: [],
34381+
rootPaths: ROOT_PATHS,
3434934382
colors: {
3435034383
primary: '#3e62f5',
3435134384
error: '#D94A4A',
3435234385
gray: '#141921'
3435334386
},
3435434387
header: {
34355-
logo: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_17__.jsx)("img", {
34388+
logo: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_18__.jsx)("img", {
3435634389
src: "https://directorist.com/wp-content/uploads/2020/08/directorist_logo.png",
3435734390
alt: "Directorist",
3435834391
width: 116

assets/src/js/react/admin/pages/app.tsx

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { addAction, applyFilters } from '@wordpress/hooks';
2+
import { useEffect } from '@wordpress/element';
23
import { Dashboard } from '@shamim-ahmed/dashboard';
34
import { RouteType } from '@shamim-ahmed/dashboard/build-types/components/dashboard/types';
45
import { MenuItemsType } from '@shamim-ahmed/dashboard/build-types/components/menu/types';
@@ -15,6 +16,11 @@ import QuestionCircleIcon from '../icons/QuestionCircleIcon';
1516
import Orders from './orders';
1617
import OrderEdit from './orders/edit';
1718

19+
// Stable reference — avoids recreating the array on every render which would
20+
// cause useActiveAdminMenu's useLayoutEffect to re-run and re-attach its
21+
// preventDefault handler, overwriting our click override below.
22+
const ROOT_PATHS: string[] = [];
23+
1824
const actionItems: MenuItemsType = {
1925
documentation: {
2026
label: 'Docs',
@@ -142,6 +148,29 @@ export default function App() {
142148
fieldValidation
143149
);
144150

151+
// Bug fix: useActiveAdminMenu (in @wpmvc/admin-sidebar) intercepts the
152+
// .wp-first-item ("All Listings") click with e.preventDefault() and tries
153+
// React Router navigation. Since rootPaths=[] there is no valid route to
154+
// navigate to, so the link silently does nothing.
155+
// We re-bind the click handler after the Dashboard's useLayoutEffect runs
156+
// (setTimeout 0 defers to the next macrotask) so it always does a full
157+
// WordPress page navigation instead.
158+
useEffect(() => {
159+
const timer = setTimeout(() => {
160+
const $ = (window as any).jQuery;
161+
if (!$) return;
162+
const $firstItem = $('#menu-posts-at_biz_dir').find('a.wp-first-item');
163+
const href = $firstItem.attr('href');
164+
if (href) {
165+
$firstItem.off('click').on('click', (e: Event) => {
166+
e.preventDefault();
167+
window.location.href = href;
168+
});
169+
}
170+
}, 0);
171+
return () => clearTimeout(timer);
172+
}, []);
173+
145174
const routes = [
146175
{
147176
path: '/',
@@ -159,7 +188,7 @@ export default function App() {
159188
<ThemeWrapper>
160189
<Dashboard
161190
pageTopLevelID="#menu-posts-at_biz_dir"
162-
rootPaths={[]}
191+
rootPaths={ROOT_PATHS}
163192
colors={{
164193
primary: '#3e62f5',
165194
error: '#D94A4A',
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-keycodes'), 'version' => '73fea3d7ff30670f65d9');
1+
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-keycodes'), 'version' => '800023f2132947142161');

0 commit comments

Comments
 (0)