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

Match dialog button layout to OS #6044

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

dhruvisompura
Copy link
Contributor

@dhruvisompura dhruvisompura commented Jan 17, 2025

This change updates the order of buttons in modals to match a user's native OS layout. The layout of buttons defaults to OS X button order when Positron is run in a web environment.

Addresses #3548

Release Notes

New Features

  • Updates modal button order to match native OS layout

Bug Fixes

  • N/A

QA Notes

  • Verify that keyboard navigation works for modals and there are no regressions with the behavior per OS
  • Verify that confirmation dialogs with an Ok and Cancel button is ordered:
    • Ok/Cancel on windows
    • Cancel/Ok on non-windows environments
  • Verify that the "Delete all variables" confirmation dialog button order is not effected by the user's OS. This modal is explicitly designed so the "Delete" action is not the first focused element and the order is always: Delete/Cancel.
  • Verify that dialogs with more than two actions split actions so that the primary action and cancel action are positioned at the right end of the modal and all other tertiary actions are positioned at the left end of the modal.

Screenshots

Screenshot 2025-01-17 at 12 21 03 PM Screenshot 2025-01-17 at 12 20 47 PM Screenshot 2025-01-17 at 12 20 39 PM Screenshot 2025-01-17 at 12 20 17 PM Screenshot 2025-01-17 at 12 20 09 PM
Screen.Recording.2025-01-17.at.12.19.49.PM.mov

@:new-project-wizard @:win

Order buttons in dialogs using the order preferred on
a platform. Default to non-windows button order when platform is indeterminable.
Some modals using the okCancelActionBar were getting the css styles for the okCancelBackNextActionBar that caused button positions to be incorrect. This avoids class style ambiguity from being applied.
Copy link

github-actions bot commented Jan 17, 2025

E2E Tests 🚀
This PR will run tests tagged with: @:critical @:new-project-wizard @:win

readme  valid tags

* @param props A PlatformNativeDialogActionBarProps that contains the component properties.
* @returns The rendered component.
*/
export const PlatformNativeDialogActionBar = ({ secondaryButton, primaryButton }: PlatformNativeDialogActionBarProps) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a super basic component that renders the primary and secondary button in the order most common for a given OS. Windows always positions the cancel/secondary button after the primary button and the inverse is true for Mac.

import { Button } from '../../../../base/browser/ui/positronComponents/button/button.js';
import { ContentArea } from './components/contentArea.js';
import { PositronModalDialog, PositronModalDialogProps } from './positronModalDialog.js';

/**
* ConfirmationModalDialogProps interface.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This component was renamed to confirmDeleteModalDialog to make it clear when to use this dialog. It currently is on only being used to create the deleteAllVariablesModalDialog and the only difference between this dialog and the ok/cancel dialog looked to be the logic to handle styling for a destructive button.

If I misunderstood what we were trying to do with this dialog or think there's issues with this change, let me know and I'll undo it!

@@ -45,22 +44,17 @@ export const ConfirmationModalDialog = (props: PropsWithChildren<ConfirmationMod
<div className='left-actions'>
</div>
<div className='right-actions'>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like we explicitly want the button order here to be delete/cancel.

This button order may seem odd to non-windows users now that we are trying to match native OS button ordering but I have left it as is for now because it looked like the button order was intentionally made so delete was the secondary action. I think we should change it to be native to the OS but would love to get thoughts on this from others.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

*/
export interface ConfirmationModalDialogProps extends PositronModalDialogProps {
export interface ConfirmDeleteModalDialogProps extends PositronModalDialogProps {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This modal has been simplified in its usage so its shown when we want a user to see a confirmation modal for a delete action. We always provide the delete action now and optionally can provide a different label for the delete action.

The secondaryActionDestructive boolean felt unnecessary to me because the OKCancelModalDialog is used when we need a basic confirmation dialog for non-destructive actions. This dialog felt like it was trying to do both even though we have a separate dialog we are using for confirming non destructive actions.

@@ -3,8 +3,7 @@
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information.
*--------------------------------------------------------------------------------------------*/

.positron-modal-dialog-box
.ok-cancel-action-bar {
.positron-modal-dialog-box .ok-cancel-back-action-bar {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I renamed the ok-cancel-action-bar class to ok-cancel-back-action-bar to avoid name collisions. The layout is different for this action bar and the OkCancelActionBar: justify-content: space-between vs justify-content: end.

This change prevents the OKCancelModalDialog using the OkCancelActionBar from having the buttons positioned incorrectly. I noticed during my testing that the styles from this sheet were overriding the styles in OkCancelActionBar which we don't want anymore.

Here's a screenshot of what was happening:
Screenshot 2025-01-17 at 3 14 12 PM

<div className='left-actions'>
{backButtonConfig ?
<Button className='button action-bar-button' onPressed={backButtonConfig.onClick} disabled={backButtonConfig.disable ?? false}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed that we had this button class added to a bunch of buttons in the modals but I couldn't find the class in any of the relevant stylesheets. I think this may be an orphaned class that was left behind by accident? I didn't see any breakage after I removed it.

Let me know if this is wrong and we do need it!

softwarenerd
softwarenerd previously approved these changes Jan 17, 2025
Copy link
Contributor

@softwarenerd softwarenerd left a comment

Choose a reason for hiding this comment

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

Looks solid!

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