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(react-draggable-dialog): create draggable dialog with handle #78

Conversation

marcosmoura
Copy link
Contributor

@marcosmoura marcosmoura commented Jan 18, 2024

Creates the base logic for a functional Draggable Dialog.
Tests will be added later to split the logic into two PRs.

The code is large as the components are too coupled tied (because of a shared context), so in case a review gets confusing, I can gladly explain all the bits.

@marcosmoura marcosmoura self-assigned this Jan 18, 2024
@marcosmoura marcosmoura added the @fluentui-contrib/react-draggable-dialog Main label for the @fluentui-contrib/react-draggable-dialog package label Jan 18, 2024
@marcosmoura marcosmoura marked this pull request as ready for review January 18, 2024 15:56
@marcosmoura marcosmoura requested review from a team as code owners January 18, 2024 15:56
@Hotell Hotell self-requested a review January 18, 2024 16:02
packages/react-draggable-dialog/package.json Show resolved Hide resolved
@@ -4,6 +4,10 @@ import { DraggableDialog } from './DraggableDialog';

describe('DraggableDialog', () => {
it('should render', () => {
render(<DraggableDialog />);
render(
Copy link
Contributor

Choose a reason for hiding this comment

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

wondering what is actual purpose of this test besides not throwing any runtime error ? which is not probably the best test

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 not supposed to be a full test, but rather a blank file ready to receive the test code. I have them done, but I'm splitting into a separate PR to make this one smaller.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO when adding logic the test should be part of the PR, otherwise we are merging something that we cannot guarantee to work heh.

but I'll leave this up to your judgement , resolving

Copy link
Contributor

Choose a reason for hiding this comment

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

unresolving ->

quite a lot logic was added to this PR , It would be great to add these tests as well as part of it. I dont feel comfortable to approve such amount of logic without any automatic verification that it works.

/**
* Text to be announced by screen readers when the dialog is dragged.
*/
announcements?: {
Copy link
Contributor

Choose a reason for hiding this comment

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

should this land on initial release ? just wondering as we are not sure if this is actually necessary ?

Copy link
Contributor Author

@marcosmoura marcosmoura Jan 30, 2024

Choose a reason for hiding this comment

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

The partners might not need announcements as an internal requirement, but they should be available and be part of an accessible Drag'n drop solution.
The announcements prop here is necessary, to translate the text that the underlying library outputs.

Copy link
Contributor

Choose a reason for hiding this comment

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

right. I dont see any default values for these, in order to enforce a11y experiences should these be required ?

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 don't know if we need it, to be honest. The DndKit library has defaults for the narration, which will happen regardless of the usage of this prop. The value of this prop here is to provide a way to translate those default messages, which are in English. Partners that don't need to fulfil the narration requirement would have to provide with their defaults for those values, which they don't need.
What do you think about this?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah we can keep it as is. I'd consider though to provide those defaults within our codebase to be explicit.

package.json Outdated Show resolved Hide resolved

const dndAnnouncements = React.useMemo(() => {
if (!announcements) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

can we change this api to be more explicit ? return null ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't set as null, because that'll mean that we don't want any accessibility props. undefined will count as "we didn't pass any value".

}

return {
onDragStart: () => announcements.start,
Copy link
Contributor

Choose a reason for hiding this comment

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

this will allow invalid behaviours, if user uses announcements={} , undefined will be passed - nothing will be announced. IMO we should make those start,end props required

Copy link
Contributor Author

@marcosmoura marcosmoura Jan 31, 2024

Choose a reason for hiding this comment

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

The DndContext has sane defaults for when any values of the announcements props are not provided. I changed the way we create the announcements object, to only include the props that are passed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see . well that's the hit n miss with 3rd party libraries as some/most things are not obvious in a PR. thank you!

@marcosmoura marcosmoura changed the title feat(react-draggable-dialog): create base logic for draggable dialogs feat(react-draggable-dialog): create draggable dialog with handle Jan 31, 2024
@marcosmoura marcosmoura merged commit 19d9745 into microsoft:main Feb 13, 2024
4 checks passed
@marcosmoura marcosmoura deleted the feat/react-draggable-dialog/create-base-components branch February 13, 2024 15:12
bsunderhus pushed a commit to bsunderhus/fluentui-contrib that referenced this pull request Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@fluentui-contrib/react-draggable-dialog Main label for the @fluentui-contrib/react-draggable-dialog package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants