8000 pagebuilder: keep scrollTop after add/delete row by molon · Pull Request #572 · qor5/admin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

pagebuilder: keep scrollTop after add/delete row #572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,6 @@ github.com/qor5/web v1.2.3 h1:OtyfFaHWTAPBz8aYvZL2/yiVf77HvlPwRkmBweKCiWs=
github.com/qor5/web v1.2.3/go.mod h1:gwAoUC1cQ9y5Vm3zZmWTq9t1iLOrQH+sIvJUpG6V61w=
github.com/qor5/web/v3 v3.0.8-0.20240910062935-ccbcae3ec022 h1:Xom8HTMTWUvJ8qEV4fNpXDlT8vzzmK6bzKjOaq1EgGQ=
github.com/qor5/web/v3 v3.0.8-0.20240910062935-ccbcae3ec022/go.mod h1:32vdHHcZb2JimlcaclW9hLUyimdXjrllZDHTh3rl6d0=
github.com/qor5/x/v3 v3.0.9-0.20240910094909-a5d7a2263c6e h1:PyzHSaRrhuIbDMri1VNk9YYl6XtnMMmDMWyoh6thtLY=
github.com/qor5/x/v3 v3.0.9-0.20240910094909-a5d7a2263c6e/go.mod h1:a+cSXd5UjIOgzhhpvfDxDUdjmKLKeDLeoubcQ9dkxtE=
github.com/qor5/x/v3 v3.0.9-0.20240910095727-21d046261590 h1:ZAbvT8GfpSPUKfB9ZWizka6z+U7bZZunrclnOm/VvjY=
github.com/qor5/x/v3 v3.0.9-0.20240910095727-21d046261590/go.mod h1:a+cSXd5UjIOgzhhpvfDxDUdjmKLKeDLeoubcQ9dkxtE=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
Expand Down
23 changes: 15 additions & 8 deletions pagebuilder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -926,14 +926,21 @@ func (b *ContainerBuilder) Model(m interface{}) *ContainerBuilder {
if portalName := ctx.Param(presets.ParamPortalName); portalName != pageBuilderRightContentPortal {
return nil
}
return web.Listen(
b.mb.NotifRowUpdated(),
web.Plaid().
URL(b.mb.Info().ListingHref()).
EventFunc(actions.Update).
Query(presets.ParamID, web.Var("payload.id")).
ThenScript(web.Plaid().EventFunc(ReloadRenderPageOrTemplateEvent).Query(paramStatus, ctx.Param(paramStatus)).MergeQuery(true).Go()).
Go(),
return h.Components(
h.Div().Style("display:none").Attr("v-on-mounted", `() => {
if (!!locals.__pageBuilderRightContentKeepScroll) {
locals.__pageBuilderRightContentKeepScroll();
}
}`),
web.Listen(
b.mb.NotifRowUpdated(),
web.Plaid().
URL(b.mb.Info().ListingHref()).
EventFunc(actions.Update).
Query(presets.ParamID, web.Var("payload.id")).
ThenScript(web.Plaid().EventFunc(ReloadRenderPageOrTemplateEvent).Query(paramStatus, ctx.Param(paramStatus)).MergeQuery(true).Go()).
Go(),
),
)
})
val := reflect.ValueOf(m)
Expand Down
12 changes: 12 additions & 0 deletions pagebuilder/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,18 @@ func (b *Builder) Editor(m *ModelBuilder) web.PageFunc {
Permanent(true).
Width(350),
VNavigationDrawer(
h.Div().Style("display:none").Attr("v-on-mounted", fmt.Sprintf(`({el}) => {
el.__handleScroll = (event) => {
locals.__pageBuilderRightContentScrollTop = event.target.scrollTop;
}
el.parentElement.addEventListener('scroll', el.__handleScroll)

locals.__pageBuilderRightContentKeepScroll = () => {
el.parentElement.scrollTop = locals.__pageBuilderRightContentScrollTop;
}
}`)).Attr("v-on-unmounted", `({el}) => {
el.parentElement.removeEventListener('scroll', el.__handleScroll);
}`),
web.Portal(editContainerDrawer).Name(pageBuilderRightContentPortal),
).Location(LocationRight).
Permanent(true).
Expand Down
Loading
0