Skip to content

Conversation

@milanbrkic-ms
Copy link
Contributor

Closes

✅ Pull Request Checklist:

  • Included link to corresponding Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exist for this component).
  • Looked at the Accessibility Standard and/or talked to @mijordan about Accessibility for this feature.

📝 Test Instructions:

🧢 Your Team:

@github-actions
Copy link

Build successful! View the storybook

@milanbrkic-ms milanbrkic-ms changed the title Rsp 1129 RSP-1129: Tag and TagGroup component Sep 26, 2019
@github-actions
Copy link

Build successful! View the storybook

@github-actions
Copy link

github-actions bot commented Oct 2, 2019

Build successful! View the storybook

@github-actions
Copy link

github-actions bot commented Oct 2, 2019

Build successful! View the storybook

@github-actions
Copy link

github-actions bot commented Oct 7, 2019

Build successful! View the storybook

Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

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

CSS review

.spectrum-Tags-item-ClearButton {
color: var(--spectrum-tag-border-color-error);
&.clearButton-focus {
color: white;
Copy link
Member

Choose a reason for hiding this comment

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

should probably be a var, i don't know which one though, @lazd can you review?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed this line - new designs 🎈

> .spectrum-Tags-item-ClearButton {
&.clearButton-focus {
background-color: var(--spectrum-tag-deletable-background-color-focus);
color: white;
Copy link
Member

Choose a reason for hiding this comment

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

same thing

Copy link
Member

Choose a reason for hiding this comment

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

Please use DNA tokens for these colors. Probably one of these:

  --spectrum-tag-removable-icon-color: var(--spectrum-global-color-gray-600);
  --spectrum-tag-removable-icon-color-hover: var(--spectrum-global-color-gray-900);
  --spectrum-tag-removable-icon-color-down: var(--spectrum-global-color-gray-900);
  --spectrum-tag-removable-icon-color-key-focus: var(--spectrum-global-color-gray-900);
  --spectrum-tag-removable-icon-color-disabled: var(--spectrum-global-color-gray-500);
  --spectrum-tag-removable-icon-color-error: var(--spectrum-global-color-red-500);
  --spectrum-tag-removable-icon-color-error-hover: var(--spectrum-global-color-red-600);
  --spectrum-tag-removable-icon-color-error-key-focus: var(--spectrum-global-color-red-600);
  --spectrum-tag-removable-icon-color-error-down: var(--spectrum-global-color-red-700);
  --spectrum-tag-removable-icon-color-error-disabled: var(--spectrum-global-color-gray-500);

Copy link
Member

Choose a reason for hiding this comment

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

If these tokens are out of date, please send a PR to Spectrum DNA: https://git.corp.adobe.com/Spectrum/spectrum-dna

import {useTag} from '@react-aria/tag';

export interface TagProps extends DOMProps {
children?: string | ReactNode,
Copy link
Member

Choose a reason for hiding this comment

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

does ReactElement cover this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it does 👍

Copy link
Member

Choose a reason for hiding this comment

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

unresolving until it's done

@milanbrkic-ms
Copy link
Contributor Author

Few notes @snowystinger :

  1. I tried to implement keyboard selection for TagGroup, but ArrowLeft wasn't working. I could commit if you want to see changes or to make follow up task for that one?
  2. onRemove is going to be called with children value. Are we fine with that? What if children is React component itself? Maybe to return value prop for tag component so we could haveonRemove(value || children)?

@github-actions
Copy link

github-actions bot commented Oct 8, 2019

Build successful! View the storybook

let {result} = renderHook(() => useTag(props));
expect(result.current.tagProps.onKeyDown).toBe(null);
expect(result.current.tagProps.tabIndex).toBe(-1);
});
Copy link
Member

Choose a reason for hiding this comment

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

Will there be tests for the clearButtonProps as well or is that a later TODO?

@github-actions
Copy link

github-actions bot commented Oct 9, 2019

Build successful! View the storybook

@github-actions
Copy link

Build successful! View the storybook

--spectrum-tag-border-color-error: rgb(236, 91, 98);
--spectrum-tag-icon-color-error: rgb(236, 91, 98);
--spectrum-tag-text-color-error: rgb(185, 185, 185);
--spectrum-tag-text-color-error: rgb(247, 109, 116);
Copy link
Member

Choose a reason for hiding this comment

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

we'll need to contribute these variable changes to spectrum-dna at some point

Copy link
Member

Choose a reason for hiding this comment

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

Yes. This is a generated file that will be overwritten. Do not edit it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is procedure?
Open pr in spectrum-dna and remove css changes from this PR and then this pr needs to wait spectrum-dna pr to be merged in order to have latest changes? Is it same if I need to add new variable? For example I used global var here https://github.com/adobe/react-spectrum-v3/pull/10/files#diff-aa7d70936a7ea3560aa2240e8e869fa5R106 and I suppose it should be --spectrum-tag-something, right?

Copy link
Member

Choose a reason for hiding this comment

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

You can update/add the variables from your DNA PR in here temporarily, and we'll regenerate it later.

onRemove,
children,
selected,
role
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 have a default role in case tag is used outside a tag group somehow?

@devongovett
Copy link
Member

FYI, we talked with design and they changed the focus style of the clear button again (sorry).

image (4)

@github-actions
Copy link

Build successful! View the storybook

@github-actions
Copy link

Build successful! View the storybook

@github-actions
Copy link

Build successful! View the storybook

@github-actions
Copy link

Build successful! View the storybook

@milanbrkic-ms
Copy link
Contributor Author

I will update css variables after https://git.corp.adobe.com/Spectrum/spectrum-dna/pull/338 is merged

@github-actions
Copy link

Build successful! View the storybook

@github-actions
Copy link

Build successful! View the storybook

</TagGroup>
)
).add(
'with announcing',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In order to have announcing you need to navigate with keyboard into first tag and then you can press ctrl+d in order to create new tag. In that moment announcing should be triggered.

id: buttonId,
title: removeString,
isDisabled,
role
Copy link
Member

Choose a reason for hiding this comment

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

It's weird to me that the labelProps and the clearButtonProps have the same role. I'd expect the role only to be on the tagProps.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be honest I am new to accessibility and nothing makes sense, but here is the comment where Michael explains why #10 (comment)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Within a TagGroup, we are implementing the WAI-ARIA 1.1 Layout Grid design pattern: https://www.w3.org/TR/wai-aria-practices/examples/grid/LayoutGrids.html#ex2_label. The TagGroup container element has role="grid". Each Tag is a row within the grid with role="row". Each Tag contains one or, if the Tag can be removed, two cells. The label will have role="gridcell", and a wrapper span element around the clear button will also have role="gridcell".

tagGroupProps: HTMLAttributes<HTMLElement>
}

export function useTagGroup(props: AriaTagGroupProps): TagGroupAria {
Copy link
Member

Choose a reason for hiding this comment

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

Should useTagGroup have tests?

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 is returning plain object, there is noting to test. But if you feel it should have, I can add

import {renderHook} from 'react-hooks-testing-library';
import {useTag} from '../';

describe('useTag tests', () => {
Copy link
Member

Choose a reason for hiding this comment

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

should 'aria-selected' be tested too?

role
} = useTagGroupProvider();

let removable = isRemovable !== undefined ? isRemovable : isGroupRemovable;
Copy link
Member

Choose a reason for hiding this comment

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

Why doesn't the group property take precedence?

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 thought we should be flexible and allow user to override flags for child elements. I am not sure if there is a need for this, but it could be useful and it doesn't breaks anything. What do you think?

import {useTag} from '@react-aria/tag';
import {useTagGroupProvider} from './TagGroup';

export const Tag = ((props: TagProps) => {
Copy link
Member

Choose a reason for hiding this comment

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

forwardRef?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we need to forward ref? And why?

return useContext(TagGroupContext);
}

export const TagGroup = ((props: TagGroupProps) => {
Copy link
Member

Choose a reason for hiding this comment

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

forwardRef?

import {Tag as V2Tag} from '@react/react-spectrum/TagList';


describe('Tag', function () {
Copy link
Member

Choose a reason for hiding this comment

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

are more tests planned?

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've added more tests

import React from 'react';
import {Tag, TagGroup} from '../src';

describe('TagGroup', function () {
Copy link
Member

Choose a reason for hiding this comment

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

are more tests planned?

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've added more tests

@github-actions
Copy link

Build successful! View the storybook

devongovett
devongovett previously approved these changes Oct 28, 2019
Copy link
Member

@devongovett devongovett left a comment

Choose a reason for hiding this comment

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

Looks good. You can do the following in a followup if you like.

import {SyntheticEvent} from 'react';

export interface Removable<T, R> {
isRemovable?: boolean,
Copy link
Member

Choose a reason for hiding this comment

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

hmm - this doesn't exist in the API spec for TagGroup. we have isReadOnly to mean this

children?: ReactChild,
icon?: ReactElement,
isDisabled?: boolean,
isSelected?: boolean,
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't be a prop of Tag - should come from context. The selection state comes from MultipleSelectionBase on the group

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 removed flag, but now I don't know how to handle selection until I have multi selection hook. I removed stories for selected Tag and overall usage. If you agree, we can implement once we have actual selection state. Maybe as part of https://jira.corp.adobe.com/browse/RSP-1357?

Milan Brkic added 2 commits October 29, 2019 12:17
  * AriaTagProps moved to @react-aria/tag package
  * Deleted isRemovable flag and its usage from TagGroup
  * Removed isSelected flag and its usage for Tag (stories removed)
@github-actions
Copy link

Build successful! View the storybook

@github-actions
Copy link

Build successful! View the storybook

@github-actions
Copy link

Build successful! View the storybook

@devongovett devongovett merged commit 74c68aa into master Oct 29, 2019
@devongovett devongovett deleted the RSP-1129 branch October 29, 2019 21:49
@github-actions
Copy link

Build successful! View the storybook

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.

8 participants