Skip to content
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

Fix profile page reorder not working without full reload #11747

Merged
merged 1 commit into from
Dec 17, 2024
Merged
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
62 changes: 32 additions & 30 deletions resources/js/profile-page/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,37 +120,39 @@ export default class Main extends React.Component<Props> {
// pageScan does not need to run at 144 fps...
$(window).on(scrollEventId, throttle(() => this.pageScan(), 20));

if (this.pages.current != null) {
$(this.pages.current).sortable({
cursor: 'move',
handle: '.js-profile-page-extra--sortable-handle',
items: '.js-sortable--page',
revert: 150,
scrollSpeed: 10,
update: this.updateOrder,
});
}
this.disposers.add(core.reactTurbolinks.runAfterPageLoad(() => {
if (this.pages.current != null) {
$(this.pages.current).sortable({
cursor: 'move',
handle: '.js-profile-page-extra--sortable-handle',
items: '.js-sortable--page',
revert: 150,
scrollSpeed: 10,
update: this.updateOrder,
});
}

if (this.tabs.current != null) {
$(this.tabs.current).sortable({
axis: 'x',
cursor: 'move',
disabled: !this.controller.withEdit,
items: '.js-sortable--tab',
revert: 150,
scrollSpeed: 0,
start: () => {
// Somehow click event still goes through when dragging.
// This prevents triggering onTabClick.
window.clearTimeout(this.timeouts.draggingTab);
this.draggingTab = true;
},
stop: () => {
this.timeouts.draggingTab = window.setTimeout(() => this.draggingTab = false, 500);
},
update: this.updateOrder,
});
}
if (this.tabs.current != null) {
$(this.tabs.current).sortable({
axis: 'x',
cursor: 'move',
disabled: !this.controller.withEdit,
items: '.js-sortable--tab',
revert: 150,
scrollSpeed: 0,
start: () => {
// Somehow click event still goes through when dragging.
// This prevents triggering onTabClick.
window.clearTimeout(this.timeouts.draggingTab);
this.draggingTab = true;
},
stop: () => {
this.timeouts.draggingTab = window.setTimeout(() => this.draggingTab = false, 500);
},
update: this.updateOrder,
});
}
}));

// preserve scroll if existing saved state but force position to reset
// on refresh to avoid browser setting scroll position at the bottom on reload.
Expand Down
Loading