@djangocfg/layouts 2.1.411 → 2.1.412

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/layouts",
3
- "version": "2.1.411",
3
+ "version": "2.1.412",
4
4
  "description": "Simple, straightforward layout components for Next.js - import and use with props",
5
5
  "keywords": [
6
6
  "layouts",
@@ -84,13 +84,13 @@
84
84
  "check": "tsc --noEmit"
85
85
  },
86
86
  "peerDependencies": {
87
- "@djangocfg/api": "^2.1.411",
88
- "@djangocfg/centrifugo": "^2.1.411",
89
- "@djangocfg/debuger": "^2.1.411",
90
- "@djangocfg/i18n": "^2.1.411",
91
- "@djangocfg/monitor": "^2.1.411",
92
- "@djangocfg/ui-core": "^2.1.411",
93
- "@djangocfg/ui-nextjs": "^2.1.411",
87
+ "@djangocfg/api": "^2.1.412",
88
+ "@djangocfg/centrifugo": "^2.1.412",
89
+ "@djangocfg/debuger": "^2.1.412",
90
+ "@djangocfg/i18n": "^2.1.412",
91
+ "@djangocfg/monitor": "^2.1.412",
92
+ "@djangocfg/ui-core": "^2.1.412",
93
+ "@djangocfg/ui-nextjs": "^2.1.412",
94
94
  "@hookform/resolvers": "^5.2.2",
95
95
  "consola": "^3.4.2",
96
96
  "lucide-react": "^0.545.0",
@@ -121,15 +121,15 @@
121
121
  "uuid": "^11.1.0"
122
122
  },
123
123
  "devDependencies": {
124
- "@djangocfg/api": "^2.1.411",
125
- "@djangocfg/centrifugo": "^2.1.411",
126
- "@djangocfg/debuger": "^2.1.411",
127
- "@djangocfg/i18n": "^2.1.411",
128
- "@djangocfg/monitor": "^2.1.411",
129
- "@djangocfg/typescript-config": "^2.1.411",
130
- "@djangocfg/ui-core": "^2.1.411",
131
- "@djangocfg/ui-nextjs": "^2.1.411",
132
- "@djangocfg/ui-tools": "^2.1.411",
124
+ "@djangocfg/api": "^2.1.412",
125
+ "@djangocfg/centrifugo": "^2.1.412",
126
+ "@djangocfg/debuger": "^2.1.412",
127
+ "@djangocfg/i18n": "^2.1.412",
128
+ "@djangocfg/monitor": "^2.1.412",
129
+ "@djangocfg/typescript-config": "^2.1.412",
130
+ "@djangocfg/ui-core": "^2.1.412",
131
+ "@djangocfg/ui-nextjs": "^2.1.412",
132
+ "@djangocfg/ui-tools": "^2.1.412",
133
133
  "@types/node": "^25.2.3",
134
134
  "@types/react": "^19.2.15",
135
135
  "@types/react-dom": "^19.2.3",
@@ -23,6 +23,8 @@ interface ErrorBoundaryState {
23
23
  }
24
24
 
25
25
  export class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
26
+ private handlePopState: (() => void) | null = null;
27
+
26
28
  constructor(props: ErrorBoundaryProps) {
27
29
  super(props);
28
30
  this.state = { hasError: false, error: null };
@@ -33,17 +35,36 @@ export class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundarySt
33
35
  }
34
36
 
35
37
  componentDidCatch(error: Error, errorInfo: ErrorInfo) {
36
- // Call custom error handler if provided
37
38
  if (this.props.onError) {
38
39
  this.props.onError(error, errorInfo);
39
40
  }
40
41
 
41
- // Log to console in development
42
42
  if (isDev) {
43
43
  console.error('ErrorBoundary caught an error:', error, errorInfo);
44
44
  }
45
45
  }
46
46
 
47
+ componentDidUpdate(_prevProps: ErrorBoundaryProps, prevState: ErrorBoundaryState) {
48
+ if (this.state.hasError && !prevState.hasError) {
49
+ this.handlePopState = () => {
50
+ window.location.reload();
51
+ };
52
+ window.addEventListener('popstate', this.handlePopState);
53
+ } else if (!this.state.hasError && prevState.hasError) {
54
+ if (this.handlePopState) {
55
+ window.removeEventListener('popstate', this.handlePopState);
56
+ this.handlePopState = null;
57
+ }
58
+ }
59
+ }
60
+
61
+ componentWillUnmount() {
62
+ if (this.handlePopState) {
63
+ window.removeEventListener('popstate', this.handlePopState);
64
+ this.handlePopState = null;
65
+ }
66
+ }
67
+
47
68
  render() {
48
69
  if (this.state.hasError) {
49
70
  const title = getT('layouts.errors.somethingWentWrong');
@@ -258,10 +258,9 @@ export function ErrorLayout({
258
258
  const handleGoBack = () => {
259
259
  if (document.referrer && document.referrer !== window.location.href) {
260
260
  window.location.href = document.referrer;
261
- } else if (window.history.length > 1) {
262
- window.history.back();
263
261
  } else {
264
- window.location.href = '/';
262
+ window.history.back();
263
+ setTimeout(() => window.location.reload(), 100);
265
264
  }
266
265
  };
267
266