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

feat: Blue dialog code snippet #2923

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

Conversation

laveshv
Copy link

@laveshv laveshv commented Oct 22, 2024

Description

Related links, issue #, if available: n/a

How has this been tested?

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@laveshv laveshv requested a review from a team as a code owner October 22, 2024 20:33
@laveshv laveshv requested review from YueyingLu and removed request for a team October 22, 2024 20:33
setShowDialog(false);
}

return showDialog ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not remove the dialog at all, we can console.log instead. I think overall the example here could be simpler.

Copy link
Author

Choose a reason for hiding this comment

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

Done in latest revision.

}

return showDialog ? (
<div className={styles['blue-dialog-box']}>
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see the a11y requirements being addressed.

Copy link
Author

Choose a reason for hiding this comment

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

I added some a11y specific code. Can you please review?

@cansuaa cansuaa changed the title Bluedialog Initial commit feat: Blue dialog code snippet Oct 24, 2024
Comment on lines 8 to 9
margin-block: 20px;
margin-inline: 20px;
border-block: 1px solid awsui.$color-border-status-info;
border-inline: 1px solid awsui.$color-border-status-info;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just margin and border? Is margin even needed?

Copy link
Author

Choose a reason for hiding this comment

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

margin and border are disallowed in the lint settings -> https://github.com/cloudscape-design/components/blob/main/.stylelintrc#L59C39-L59C74

Actually, we can remove the margin. Just that it wasn't looking very good on my whole page. It was spreading on the whole page. So, I introduced it.

Comment on lines +34 to +33
padding-block: 10px;
padding-inline: 10px;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

Copy link
Author

Choose a reason for hiding this comment

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

role={'dialog'}
aria-labelledby="dialog-title"
aria-modal="false" // Maintains natural focus flow since it's an inline dialog
tabIndex={-1} // This allows the dialog to receive focus
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the value should be 0 not -1

Copy link
Member

Choose a reason for hiding this comment

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

-1 means the dialog can only be focused programmatically which is good for one-time focus when it appears. I think making it user-focusable is not needed.

Copy link
Member

Choose a reason for hiding this comment

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

In either case, it would be great to show this focusing behaviour in action.

Copy link

codecov bot commented Oct 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.25%. Comparing base (041e7e5) to head (277560b).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2923   +/-   ##
=======================================
  Coverage   96.24%   96.25%           
=======================================
  Files         769      769           
  Lines       21722    21744   +22     
  Branches     7371     7379    +8     
=======================================
+ Hits        20907    20929   +22     
  Misses        762      762           
  Partials       53       53           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

aria-modal="false" // Maintains natural focus flow since it's an inline dialog
tabIndex={-1} // This allows the dialog to receive focus
>
<Form
Copy link
Member

Choose a reason for hiding this comment

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

Should we also use a semantic form element and support onSubmit?

Copy link
Author

Choose a reason for hiding this comment

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

Actually we can, but then I did not see the onSubmit event in the

component of clouscape, so wanted to navigate away from that practice. Also, it adds some over burden of styling that semantic element.


import styles from './styles.scss';

export default function Bluedialogbox() {
Copy link
Member

Choose a reason for hiding this comment

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

Should we separate page and component?

Say, we can have some BluedialogPage that renders the screenshot area maybe and some additional heading (needed for a11y static checks anyways) etc. and the Bluedialog component that can also take some onSubmit/onCancel props and maybe some other, showcasing the actual design of the component?

Copy link
Author

@laveshv laveshv Oct 29, 2024

Choose a reason for hiding this comment

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

Actually, the approach that we decided was that we will not create any built-in component for this request. This whole tasks would be to just create a code snippet that the users can copy and use, with minimum changes from their end.

Also, I think this folder, might not be the right place for this code. So, please feel free to suggest if there is a better place to put these files

Copy link
Contributor

@cansuaa cansuaa Nov 4, 2024

Choose a reason for hiding this comment

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

I believe Andrei's suggesting to do it this way so that customers would directly be able to copy the "component". Similarly the reason why he suggested to put the functions like onCancel outside of the "component"


useEffect(() => {
// Store the element that had focus before dialog opened
triggerRef.current = document.activeElement as HTMLElement;
Copy link
Member

Choose a reason for hiding this comment

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

If the dialog is opened programmatically this transition can be weird. Would it be better to handle the focus transition on the outside? If the parent component provides onSubmit/onCancel then the focus transition can be done as part of it:

function ParentComponent() {
  // ...
  
  function returnFocus() {
    sendButtonRef.current?.focus()
  }
  
  function onSubmit() {
    // submit
    returnFocus();
  }
  
  function onCancel() {
    // cancel
    returnFocus();
  }
  
  return (
    <div>
      // ...
      <Bluedialog onSubmit={onSubmit} onCancel={onCancel} />
    </div>
  );
}

Copy link
Author

Choose a reason for hiding this comment

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

Like I mentioned previously, this is just a code snippet. It is upto the individual users on how they want to use it.

@cansuaa cansuaa marked this pull request as draft October 29, 2024 14:11
@cansuaa cansuaa removed the request for review from YueyingLu October 29, 2024 14:11
@laveshv
Copy link
Author

laveshv commented Oct 30, 2024

I refactored this little code little bit. Converted BluedialogPage into a parent page and move all its code to child component dialog

@laveshv laveshv marked this pull request as ready for review October 30, 2024 21:13
@cansuaa cansuaa marked this pull request as draft November 4, 2024 13:42
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.

3 participants