Skip to content

sticky controls - #5106

Merged
stuartromanek merged 10 commits into
mainfrom
sticky-widget-controls
Oct 20, 2025
Merged

stuartromanek merged 10 commits into
mainfrom
sticky-widget-controls

Conversation

@stuartromanek

@stuartromanek stuartromanek commented Oct 13, 2025 •

Copy link
Copy Markdown
Member

Custom sticky positioning for widget controls

  • Keeps controls in view no matter how tall widget
  • is aware of the admin bar and gets out of the way
  • tolerates a certain amount of window resizing and 'does the right thing'
sticky.mp4

@stuartromanek
stuartromanek requested a review from ValJed October 13, 2025 20:22
@stuartromanek stuartromanek changed the title sticky controls attempt 1 sticky controls Oct 14, 2025

@ValJed ValJed left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat feature 👍🏼
Minor feedback.

One thing: Are you sure we cannot use position: sticky to do this with less complexity.
I quickly tried to put the controls inside the guard and it looks almost working (the scroll thing), still should handle the admin bar etc.
Just checking with you since it would make the code way easier to maintain.

For the cypress tests, you can verify that when a widget is half visible, the controls are still visible for example. Would also make sense to run existing to be sure it breaks nothing.

Comment thread modules/@apostrophecms/area/ui/apos/components/AposAreaWidget.vue Outdated
Comment thread modules/@apostrophecms/area/ui/apos/components/AposAreaWidget.vue Outdated

this.scrollTicking = true;
}
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one could be splitted in two.
this function in charge of the overall logic, and another function in charge of computing the newStyles and returning it.
Would make the code more readable, and remove hard to track reassignment.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this by

  • statically composing the default and bottom positions inside data as these don't change and aren't subject to the window
  • Add a method computing the floating style, as it requires the latest widgetRect to compute the right prop
  • Add a method for conditionally updating the styles that both handlers use

lmk what you think

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes better !

this.stickyControlsStyles = newStyles;
}

this.scrollTicking = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is set to false on every frame, is it intentional?
It's purpose is to know if some scroll logic is running right?
Maybe this.scrollTicking = true; should be at the start of the frame cb?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it’s set to true right after scheduling (not inside) because requestAnimationFrame is async — setting it earlier prevents multiple frames from being queued before the first one runs. it’s reset to false at the end of the callback to allow the next frame.

@stuartromanek
stuartromanek requested a review from ValJed October 16, 2025 11:06
@stuartromanek

Copy link
Copy Markdown
Member Author

@stuartromanek

Copy link
Copy Markdown
Member Author

ValJed
ValJed previously approved these changes Oct 20, 2025

@ValJed ValJed left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!


this.scrollTicking = true;
}
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes better !

@stuartromanek
stuartromanek merged commit b1d7bf7 into main Oct 20, 2025
9 checks passed
@stuartromanek
stuartromanek deleted the sticky-widget-controls branch October 20, 2025 14:40
haroun added a commit that referenced this pull request Oct 21, 2025
* main:
  enforce empty state font (#5113)
  sticky controls (#5106)
  Layout widget icon (#5112)
  Feature layout widget (#5031)
  PRO-8435: log what widget type was missing (#5110)
  fix changelog (#5108)
  take aspect ratio into account to calculate min size constrain (#5087)
  PRO-8343: render-areas=inline support when using an external frontend (#5092)
haroun added a commit that referenced this pull request Oct 21, 2025
* main:
  add locale picker (#5090)
  enforce empty state font (#5113)
  sticky controls (#5106)
  Layout widget icon (#5112)
  Feature layout widget (#5031)
  PRO-8435: log what widget type was missing (#5110)
  fix changelog (#5108)
  take aspect ratio into account to calculate min size constrain (#5087)
  PRO-8343: render-areas=inline support when using an external frontend (#5092)
haroun added a commit that referenced this pull request Oct 29, 2025
…ation

* main: (23 commits)
  PRO-8538: fix layout bug in mobile breakpoint preview that causes tiny collapsed columns (#5127)
  give color button a testable data attr (#5124)
  PRO-8530 autodetect ES bundles (#5120)
  Emphasize but unfocus in layout mode (#5125)
  Simplify layout max width (#5123)
  max width, anchors, labels (#5122)
  refactor and inject admin UI styles for layout (#5116)
  Color field swatches (#5118)
  Pro 8285 login case insensitive (#5100)
  fix paste bug (#5119)
  Implement change outlined on Discord (#5117)
  PRO-8374: Mute tooltip when edit is disabled (#5114)
  fix sticky when controls are disabled (#5115)
  enable logout and whoami routes if localLogin is false (#5098)
  add locale picker (#5090)
  enforce empty state font (#5113)
  sticky controls (#5106)
  Layout widget icon (#5112)
  Feature layout widget (#5031)
  PRO-8435: log what widget type was missing (#5110)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants