Skip to content

Commit de67317

Browse files
authored
fix: Database notification not closing on navigate (#20046)
1 parent 14ec5ad commit de67317

3 files changed

Lines changed: 19 additions & 14 deletions

File tree

packages/actions/src/Action.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ public function getAlpineClickHandler(): ?string
417417
}
418418

419419
if ($this->shouldClose()) {
420-
return 'close()';
420+
return (filled($this->getUrl()) && (! $this->shouldOpenUrlInNewTab())) ? 'close(true)' : 'close()';
421421
}
422422

423423
if ($this->shouldMarkAsRead()) {

packages/notifications/dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/notifications/resources/js/components/notification.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,20 +130,25 @@ export default (Alpine) => {
130130
)
131131
},
132132

133-
close() {
133+
close(isImmediate = false) {
134134
this.isShown = false
135135

136-
setTimeout(
137-
() =>
138-
window.dispatchEvent(
139-
new CustomEvent('notificationClosed', {
140-
detail: {
141-
id: notification.id,
142-
},
143-
}),
144-
),
145-
this.transitionDuration,
146-
)
136+
const dispatchClosedEvent = () =>
137+
window.dispatchEvent(
138+
new CustomEvent('notificationClosed', {
139+
detail: {
140+
id: notification.id,
141+
},
142+
}),
143+
)
144+
145+
if (isImmediate === true) {
146+
dispatchClosedEvent()
147+
148+
return
149+
}
150+
151+
setTimeout(dispatchClosedEvent, this.transitionDuration)
147152
},
148153

149154
markAsRead() {

0 commit comments

Comments
 (0)