@inertiaui/modal-react 3.0.0 → 3.0.1
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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inertiaui/modal-react",
|
|
3
3
|
"author": "Pascal Baljet <pascal@protone.media>",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -64,4 +64,4 @@
|
|
|
64
64
|
"react": "^19.0.0",
|
|
65
65
|
"react-dom": "^19.0.0"
|
|
66
66
|
}
|
|
67
|
-
}
|
|
67
|
+
}
|
package/src/HeadlessModal.tsx
CHANGED
|
@@ -138,7 +138,7 @@ const HeadlessModal = forwardRef<HeadlessModalRef, HeadlessModalProps>(
|
|
|
138
138
|
const previousIsOpenRef = useRef<boolean | undefined>(undefined)
|
|
139
139
|
|
|
140
140
|
useEffect(() => {
|
|
141
|
-
if (modalContext
|
|
141
|
+
if (modalContext != null) {
|
|
142
142
|
if (modalContext.isOpen) {
|
|
143
143
|
onSuccess?.()
|
|
144
144
|
} else if (previousIsOpenRef.current === true) {
|
|
@@ -153,7 +153,7 @@ const HeadlessModal = forwardRef<HeadlessModalRef, HeadlessModalProps>(
|
|
|
153
153
|
const [rendered, setRendered] = useState(false)
|
|
154
154
|
|
|
155
155
|
useEffect(() => {
|
|
156
|
-
if (rendered && modalContext
|
|
156
|
+
if (rendered && modalContext != null && modalContext.isOpen) {
|
|
157
157
|
if (modalContext.onTopOfStack) {
|
|
158
158
|
onFocus?.()
|
|
159
159
|
} else {
|
package/src/ModalRoot.tsx
CHANGED
|
@@ -260,7 +260,11 @@ export const ModalStackProvider = ({ children }: ModalStackProviderProps) => {
|
|
|
260
260
|
// Only suppresses navigate events to this specific URL
|
|
261
261
|
closingToBaseUrlTarget = savedBaseUrl
|
|
262
262
|
|
|
263
|
-
|
|
263
|
+
// Only call router.push() when the URL actually changed (navigate mode).
|
|
264
|
+
// In non-navigate mode (default), the URL never changes and _inertiaui_modal
|
|
265
|
+
// is never in page props, so router.push() would be a no-op that triggers
|
|
266
|
+
// an unnecessary full component re-render in Inertia v3.
|
|
267
|
+
if (savedBaseUrl && typeof window !== 'undefined' && !sameUrlPath(savedBaseUrl, window.location.href)) {
|
|
264
268
|
router.push({
|
|
265
269
|
url: savedBaseUrl,
|
|
266
270
|
preserveScroll: true,
|