A platform for community discussion. Free, open, simple.
DEV: Unify on-resize modifier situation (#30415)
Jarek Radosz3c95aceeb0d0
diff --git a/app/assets/javascripts/discourse/app/components/horizontal-overflow-nav.hbs b/app/assets/javascripts/discourse/app/components/horizontal-overflow-nav.hbsindex 43302b0d661..5c5685974d8 100644--- a/app/assets/javascripts/discourse/app/components/horizontal-overflow-nav.hbs+++ b/app/assets/javascripts/discourse/app/components/horizontal-overflow-nav.hbs@@ -22,8 +22,8 @@{{/if}}<ul- {{on-resize this.checkScroll}}- {{on "scroll" this.watchScroll}}+ {{on-resize this.onResize}}+ {{on "scroll" this.onScroll}}{{did-insert this.scrollToActive}}{{on "mousedown" this.scrollDrag}}class="nav-pills action-list {{@className}}"diff --git a/app/assets/javascripts/discourse/app/components/horizontal-overflow-nav.js b/app/assets/javascripts/discourse/app/components/horizontal-overflow-nav.jsindex 594764d5e76..2c58febf46a 100644--- a/app/assets/javascripts/discourse/app/components/horizontal-overflow-nav.js+++ b/app/assets/javascripts/discourse/app/components/horizontal-overflow-nav.js@@ -22,13 +22,14 @@ export default class HorizontalOverflowNav extends Component {}@bind- checkScroll(event) {+ onResize(entries) {if (this.site.mobileView) {return;}- this.watchScroll(event);- this.hasScroll = event.target.scrollWidth > event.target.offsetWidth;+ const element = entries[0].target;+ this.watchScroll(element);+ this.hasScroll = element.scrollWidth > element.offsetWidth;}@bind@@ -37,22 +38,23 @@ export default class HorizontalOverflowNav extends Component {}@bind- watchScroll(event) {+ onScroll(event) {if (this.site.mobileView) {return;}- if (- event.target.offsetWidth + event.target.scrollLeft ===- event.target.scrollWidth- ) {+ this.watchScroll(event.target);+ }++ watchScroll(element) {+ if (element.offsetWidth + element.scrollLeft === element.scrollWidth) {this.hideRightScroll = true;clearInterval(this.scrollInterval);} else {this.hideRightScroll = false;}- if (event.target.scrollLeft === 0) {+ if (element.scrollLeft === 0) {this.hideLeftScroll = true;clearInterval(this.scrollInterval);} else {diff --git a/plugins/chat/assets/javascripts/discourse/modifiers/chat/on-resize.js b/app/assets/javascripts/discourse/app/modifiers/on-resize.jssimilarity index 92%rename from plugins/chat/assets/javascripts/discourse/modifiers/chat/on-resize.jsrename to app/assets/javascripts/discourse/app/modifiers/on-resize.jsindex 802901fcc23..ef0278d4a17 100644--- a/plugins/chat/assets/javascripts/discourse/modifiers/chat/on-resize.js+++ b/app/assets/javascripts/discourse/app/modifiers/on-resize.js@@ -2,7 +2,7 @@ import { registerDestructor } from "@ember/destroyable";import { cancel, throttle } from "@ember/runloop";import Modifier from "ember-modifier";-export default class ChatOnResize extends Modifier {+export default class OnResize extends Modifier {constructor(owner, args) {super(owner, args);registerDestructor(this, (instance) => instance.cleanup());diff --git a/app/assets/javascripts/discourse/package.json b/app/assets/javascripts/discourse/package.jsonindex 851fd28d55b..afe06ae707e 100644--- a/app/assets/javascripts/discourse/package.json+++ b/app/assets/javascripts/discourse/package.json@@ -96,7 +96,6 @@"ember-exam": "^9.0.0","ember-load-initializers": "^3.0.1","ember-modifier": "^4.2.0",- "ember-on-resize-modifier": "^2.0.2","ember-qunit": "^9.0.1","ember-source": "~5.12.0","ember-template-imports": "^4.2.0",diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-messages-container.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-messages-container.gjsindex 629ff1cc819..7f0bdcb6088 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-messages-container.gjs+++ b/plugins/chat/assets/javascripts/discourse/components/chat-messages-container.gjs@@ -1,10 +1,10 @@import { hash } from "@ember/helper";-import ChatOnResize from "../modifiers/chat/on-resize";+import onResize from "discourse/modifiers/on-resize";const ChatMessagesContainer = <template><divclass="chat-messages-container"- {{ChatOnResize @didResizePane (hash delay=100 immediate=true)}}+ {{onResize @didResizePane (hash delay=100 immediate=true)}}>{{yield}}</div>diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/navbar/index.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/navbar/index.gjsindex d3cc0375b79..e8ace0fa333 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat/navbar/index.gjs+++ b/plugins/chat/assets/javascripts/discourse/components/chat/navbar/index.gjs@@ -4,7 +4,7 @@ import { on } from "@ember/modifier";import { action } from "@ember/object";import concatClass from "discourse/helpers/concat-class";import noop from "discourse/helpers/noop";-import ChatOnResize from "../../../modifiers/chat/on-resize";+import onResize from "discourse/modifiers/on-resize";import Actions from "./actions";import BackButton from "./back-button";import ChannelTitle from "./channel-title";@@ -30,7 +30,7 @@ export default class ChatNavbar extends Component {<divclass={{concatClass "c-navbar-container" (if @onClick "-clickable")}}{{on "click" (if @onClick @onClick (noop))}}- {{ChatOnResize this.handleResize}}+ {{onResize this.handleResize}}><nav class="c-navbar">{{yielddiff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 214f8b50414..b781fc8a30f 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -504,9 +504,6 @@ importers:ember-modifier:specifier: ^4.2.0version: 4.2.0(@babel/[email protected])([email protected](patch_hash=xx7mvsb7nmshqkkqhmf45r3hse)(@glimmer/[email protected](@babel/[email protected]))(@glint/[email protected])([email protected])([email protected](@swc/[email protected])([email protected])))- ember-on-resize-modifier:- specifier: ^2.0.2- version: 2.0.2(@babel/[email protected])(@glint/[email protected])([email protected](patch_hash=xx7mvsb7nmshqkkqhmf45r3hse)(@glimmer/[email protected](@babel/[email protected]))(@glint/[email protected])([email protected])([email protected](@swc/[email protected])([email protected])))([email protected](@swc/[email protected])([email protected]))ember-qunit:specifier: ^9.0.1version: 9.0.1(@ember/[email protected](@babel/[email protected])(@glint/[email protected])([email protected](patch_hash=xx7mvsb7nmshqkkqhmf45r3hse)(@glimmer/[email protected](@babel/[email protected]))(@glint/[email protected])([email protected])([email protected](@swc/[email protected])([email protected]))))(@glint/[email protected])([email protected](patch_hash=xx7mvsb7nmshqkkqhmf45r3hse)(@glimmer/[email protected](@babel/[email protected]))(@glint/[email protected])([email protected])([email protected](@swc/[email protected])([email protected])))([email protected])@@ -744,7 +741,7 @@ importers:version: 4.2.0ember-this-fallback:specifier: ^0.4.0- version: 0.4.0(patch_hash=znalyv6akdxlqfpmxunrdi3osa)([email protected])([email protected](patch_hash=xx7mvsb7nmshqkkqhmf45r3hse)(@glimmer/[email protected](@babel/[email protected]))(@glint/[email protected])([email protected]))+ version: 0.4.0(patch_hash=znalyv6akdxlqfpmxunrdi3osa)([email protected])([email protected](patch_hash=xx7mvsb7nmshqkkqhmf45r3hse)(@glimmer/[email protected](@babel/[email protected]))(@glint/[email protected])([email protected])([email protected](@swc/[email protected])([email protected])))devDependencies:ember-cli:specifier: ~6.0.1@@ -1087,7 +1084,7 @@ importers:version: 5.12.0(patch_hash=xx7mvsb7nmshqkkqhmf45r3hse)(@glimmer/[email protected](@babel/[email protected]))(@glint/[email protected])([email protected])([email protected](@swc/[email protected])([email protected]))ember-this-fallback:specifier: ^0.4.0- version: 0.4.0(patch_hash=znalyv6akdxlqfpmxunrdi3osa)([email protected])([email protected](patch_hash=xx7mvsb7nmshqkkqhmf45r3hse)(@glimmer/[email protected](@babel/[email protected]))(@glint/[email protected])([email protected]))+ version: 0.4.0(patch_hash=znalyv6akdxlqfpmxunrdi3osa)([email protected])([email protected](patch_hash=xx7mvsb7nmshqkkqhmf45r3hse)(@glimmer/[email protected](@babel/[email protected]))(@glint/[email protected])([email protected])([email protected](@swc/[email protected])([email protected])))handlebars:specifier: ^4.7.8version: 4.7.8@@ -4392,10 +4389,6 @@ packages:ember-source:optional: true- resolution: {integrity: sha512-7mcD7CNbiCaZEIASWlRz/Wmn47afCMSFTdQJSSUe0WCgnXxn9DVoqZ39B7ZuddTHa0V6otTFrV/lIRYpggQ+eg==}- engines: {node: 12.* || 14.* || >= 16}-resolution: {integrity: sha512-9DgjczFG7ZjINmwWFYDtUF8McbYqQir82hyFp/ZbMOLkpFvHCKPw1mtKcpcdLnLAAYJpwR2/MCyPNiEMkR11aA==}peerDependencies:@@ -4403,10 +4396,6 @@ packages:ember-source: '>=4.0.0'qunit: ^2.13.0- resolution: {integrity: sha512-/vbfxtHSyOGSNdjPKL8X3SyvUnYo3z88sJtD/bLJ0ZGhqVPaXCmtSkLyr/Fh75ckJDixRFxK4i4zEUSlrbk0PA==}- engines: {node: 12.* || 14.* || >= 16}-resolution: {integrity: sha512-t/PjXLCl5tM9EQXGIFoBgHiA41HkLJpfo17Nud5Cy9eyUPGcnsMjWJqQ+O5QHA0E63Sp+zTn4y/RS5Tu2v2ydg==}engines: {node: 14.* || 16.* || >= 18}@@ -12684,20 +12673,6 @@ snapshots:- '@babel/core'- supports-color- [email protected](@babel/[email protected])(@glint/[email protected])([email protected](patch_hash=xx7mvsb7nmshqkkqhmf45r3hse)(@glimmer/[email protected](@babel/[email protected]))(@glint/[email protected])([email protected])([email protected](@swc/[email protected])([email protected])))([email protected](@swc/[email protected])([email protected])):- dependencies:- ember-auto-import: 2.10.0(@glint/[email protected])([email protected](@swc/[email protected])([email protected]))- ember-cli-babel: 7.26.11- ember-cli-htmlbars: 5.7.2- ember-modifier: 4.2.0(@babel/[email protected])([email protected](patch_hash=xx7mvsb7nmshqkkqhmf45r3hse)(@glimmer/[email protected](@babel/[email protected]))(@glint/[email protected])([email protected])([email protected](@swc/[email protected])([email protected])))- ember-resize-observer-service: 1.1.0- transitivePeerDependencies:- - '@babel/core'- - '@glint/template'- - ember-source- - supports-color- - webpack-[email protected](@ember/[email protected](@babel/[email protected])(@glint/[email protected])([email protected](patch_hash=xx7mvsb7nmshqkkqhmf45r3hse)(@glimmer/[email protected](@babel/[email protected]))(@glint/[email protected])([email protected])([email protected](@swc/[email protected])([email protected]))))(@glint/[email protected])([email protected](patch_hash=xx7mvsb7nmshqkkqhmf45r3hse)(@glimmer/[email protected](@babel/[email protected]))(@glint/[email protected])([email protected])([email protected](@swc/[email protected])([email protected])))([email protected]):dependencies:'@ember/test-helpers': 4.0.4(@babel/[email protected])(@glint/[email protected])([email protected](patch_hash=xx7mvsb7nmshqkkqhmf45r3hse)(@glimmer/[email protected](@babel/[email protected]))(@glint/[email protected])([email protected])([email protected](@swc/[email protected])([email protected])))@@ -12710,13 +12685,6 @@ snapshots:- '@glint/template'- supports-color- dependencies:- ember-cli-babel: 7.26.11- ember-cli-htmlbars: 5.7.2- transitivePeerDependencies:- - supports-color-[email protected]([email protected](patch_hash=xx7mvsb7nmshqkkqhmf45r3hse)(@glimmer/[email protected](@babel/[email protected]))(@glint/[email protected])([email protected])([email protected](@swc/[email protected])([email protected]))):dependencies:ember-cli-babel: 7.26.11@@ -12866,7 +12834,7 @@ snapshots:transitivePeerDependencies:- supports-color- [email protected](patch_hash=znalyv6akdxlqfpmxunrdi3osa)([email protected])([email protected](patch_hash=xx7mvsb7nmshqkkqhmf45r3hse)(@glimmer/[email protected](@babel/[email protected]))(@glint/[email protected])([email protected])):+ [email protected](patch_hash=znalyv6akdxlqfpmxunrdi3osa)([email protected])([email protected](patch_hash=xx7mvsb7nmshqkkqhmf45r3hse)(@glimmer/[email protected](@babel/[email protected]))(@glint/[email protected])([email protected])([email protected](@swc/[email protected])([email protected]))):dependencies:'@glimmer/syntax': 0.84.3babel-plugin-ember-template-compilation: 2.2.5