Repository navigation
Media Editor Modal: Try placing the save and cancel buttons in the footer #78708
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
andrewserong
merged 5 commits into
trunk
from
try/media-editor-place-save-cancel-buttons-in-the-footer
May 28, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9483f0e
Media Editor Modal: Try out placing the save and cancel buttons in th…
andrewserong 0e2ec0a
Update tsconfig
andrewserong d0cfec9
Reorganise things a little better
andrewserong b8e4c8b
Try breaking the controls up into separate groups to allow three diff…
andrewserong ad05699
Add wrap if it's really needed
andrewserong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
packages/media-editor/src/components/media-editor-fine-rotation/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| import { __ } from '@wordpress/i18n'; | ||
|
|
||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import { useMediaEditor } from '../../state'; | ||
| import { useCropGestureHandlers } from '../../hooks/use-crop-gesture-handlers'; | ||
| import { MAX_ROTATION_OFFSET } from '../../image-editor/core/constants'; | ||
| import RotationRuler from '../rotation-ruler'; | ||
|
|
||
| export interface MediaEditorFineRotationProps { | ||
| /** Signal that a placement-oriented control is being adjusted. */ | ||
| onPlacementControlInteraction?: () => void; | ||
| } | ||
|
|
||
| /** | ||
| * Fine-rotation slider for the media-editor footer. Lives separately from | ||
| * the snap-rotate / flip buttons so the footer can place the two halves on | ||
| * different rows at intermediate viewport widths. | ||
| * | ||
| * @param props | ||
| * @param props.onPlacementControlInteraction | ||
| */ | ||
| export default function MediaEditorFineRotation( { | ||
| onPlacementControlInteraction, | ||
| }: MediaEditorFineRotationProps ) { | ||
| const { state, setRotation } = useMediaEditor(); | ||
| // `commitOnKeyUp: false` lets rapid arrow-key adjustments coalesce | ||
| // into one undo entry via the gesture idle window. Pointer-up still | ||
| // closes pointer drags immediately. | ||
| const rotationGestureHandlers = useCropGestureHandlers( { | ||
| commitOnKeyUp: false, | ||
| } ); | ||
|
|
||
| // `setRotation` is an absolute-angle setter. When a single flip is active | ||
| // the visual direction inverts, so slider input must flip sign to match | ||
| // what the user sees. `snapRotate90` already handles this internally. | ||
| const baseAngle = Math.round( state.rotation / 90 ) * 90; | ||
| const singleFlip = state.flip.horizontal !== state.flip.vertical; | ||
| const visualDir = singleFlip ? -1 : 1; | ||
| const fineOffset = ( state.rotation - baseAngle ) * visualDir; | ||
|
|
||
| const handleRotationSlider = ( value: number ) => { | ||
| // Clamp strictly inside [-MAX, MAX). Exactly ±MAX lands state on a | ||
| // 90° midpoint and flips the derived baseAngle on the next render, | ||
| // causing subsequent events to spiral. | ||
| const EPS = 0.01; | ||
| const clamped = Math.max( | ||
| -MAX_ROTATION_OFFSET + EPS, | ||
| Math.min( MAX_ROTATION_OFFSET - EPS, value ) | ||
| ); | ||
| onPlacementControlInteraction?.(); | ||
| setRotation( baseAngle + clamped * visualDir ); | ||
| }; | ||
|
|
||
| return ( | ||
| <div | ||
| role="presentation" | ||
| className="media-editor-fine-rotation" | ||
| { ...rotationGestureHandlers } | ||
| > | ||
| <RotationRuler | ||
| label={ __( 'Fine rotation' ) } | ||
| min={ -MAX_ROTATION_OFFSET } | ||
| max={ MAX_ROTATION_OFFSET } | ||
| value={ fineOffset } | ||
| onChange={ handleRotationSlider } | ||
| /> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also be
flex: 1I guess. Not a biggie.