-
Notifications
You must be signed in to change notification settings - Fork 155
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
base: main
Are you sure you want to change the base?
Conversation
pages/bluedialog/bluedialog.page.tsx
Outdated
setShowDialog(false); | ||
} | ||
|
||
return showDialog ? ( |
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.
Let's not remove the dialog at all, we can console.log instead. I think overall the example here could be simpler.
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.
Done in latest revision.
pages/bluedialog/bluedialog.page.tsx
Outdated
} | ||
|
||
return showDialog ? ( | ||
<div className={styles['blue-dialog-box']}> |
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.
I don't see the a11y requirements being addressed.
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.
I added some a11y specific code. Can you please review?
pages/bluedialog/styles.scss
Outdated
margin-block: 20px; | ||
margin-inline: 20px; | ||
border-block: 1px solid awsui.$color-border-status-info; | ||
border-inline: 1px solid awsui.$color-border-status-info; |
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.
Why not just margin and border? Is margin even needed?
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.
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.
padding-block: 10px; | ||
padding-inline: 10px; |
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.
Same here
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.
pages/bluedialog/bluedialog.page.tsx
Outdated
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 |
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.
I believe the value should be 0 not -1
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.
-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.
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.
In either case, it would be great to show this focusing behaviour in action.
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
pages/bluedialog/bluedialog.page.tsx
Outdated
aria-modal="false" // Maintains natural focus flow since it's an inline dialog | ||
tabIndex={-1} // This allows the dialog to receive focus | ||
> | ||
<Form |
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.
Should we also use a semantic form element and support onSubmit?
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.
Actually we can, but then I did not see the onSubmit
event in the
pages/bluedialog/bluedialog.page.tsx
Outdated
|
||
import styles from './styles.scss'; | ||
|
||
export default function Bluedialogbox() { |
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.
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?
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.
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
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.
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"
pages/bluedialog/bluedialog.page.tsx
Outdated
|
||
useEffect(() => { | ||
// Store the element that had focus before dialog opened | ||
triggerRef.current = document.activeElement as HTMLElement; |
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.
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>
);
}
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.
Like I mentioned previously, this is just a code snippet. It is upto the individual users on how they want to use it.
I refactored this little code little bit. Converted |
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
CONTRIBUTING.md
.CONTRIBUTING.md
.Security
checkSafeUrl
function.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.