Skip to content

Conversation

intergalacticspacehighway
Copy link
Contributor

Closes

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub 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 exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

  • Check Storybook examples of tabs and yarn test tabs
  • Also, added an example of a custom layout in Storybook.

🧢 Your Project:

GeekyAnts/NativeBase

P.S. I'll update the documentation once the changes are approved as I am not sure we need TabList and TabPanels as collection components in stately. I think React Aria users can use them as normal components and restrict them to accept Collection Item components just like Spectrum.

Copy link
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! Just had a couple of comments (and some nitpicks about tab spaces that I'll go ahead and fix myself).

state: SingleSelectListState<T>,
ref: RefObject<HTMLElement>
): TabAria {
let {item, isDisabled: propsDisabled} = props;
Copy link
Member

Choose a reason for hiding this comment

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

IMO it feels a bit unwieldy to have the item passed in as a prop, especially if we just need the key from it. What do you think about accepting a key instead? I figure it would be more flexible for users who consume useTab as a standalone hook

export interface TabListState<T> extends SingleSelectListState<T> {}

export function useTabsState<T extends object>(props: TabsProps<T>): TabsState<T> {
export function useTabListState<T extends object>(props: TabListProps<T>): TabListState<T> {
Copy link
Member

Choose a reason for hiding this comment

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

Might want to rename the file to useTabListState to prevent confusion but not the biggest deal

Comment on lines +55 to +59
items?: Iterable<T>,
keyboardActivation?: 'automatic' | 'manual',
orientation?: Orientation,
isDisabled?: boolean,
disabledKeys?: Iterable<Key>,
Copy link
Member

Choose a reason for hiding this comment

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

Note for future work: will need to update docs and type descriptions here before releasing this update.
No need to handle in this pull, marking this as a reminder for the team

className,
...otherProps
} = props;
export const TabList = function <T> (props: SpectrumTabListProps<T>) {
Copy link
Member

Choose a reason for hiding this comment

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

Since TabList and TabPanel are now exposed to the user, I'm wondering if we wanna support any style props/UNSAFE_classNames on those components for further customization. Might not need them since we can wrap them in things like Flex/other layout components though.

</Item>
</TabList>
<TabPanels>
<Item key="dashboard">
Copy link
Member

Choose a reason for hiding this comment

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

The TabPanel items will throw a warning here since there isn't a textValue provided. I wonder if we should modify Item.ts so that a textValue isn't explicitly required since the TabList and TabPanel items don't support typeahead anyways.

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.

Just a point of note for the team before release, I don't think we want to export Tab
in Tabs.tsx we've already been
export function Tab<T>...
but I don't see any place it's used, I think it's only internal to that file

honestly looks really good, thank you!


const {tabListProps} = useTabList({...tabProps, ...props}, state, tablistRef);

useEffect(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Should this be useLayoutEffect? actual question, I haven't thought it through completely

general thought is
seems like there might be a period of time where id's are being actually rendered with undefined, if we push it to useLayouEffect, then that won't actually leave the virtual dom, it'll be updated before it's flushed.
but it may not be a real issue

let {tabListProps, tabPanelProps} = useTabs(props, state, tablistRef);
let [collapse, setCollapse] = useValueEffect(false);
let [selectedTab, setSelectedTab] = useState<HTMLElement>();
const [tabListState, setTabListState] = React.useState<TabListState<T>>(null);
Copy link
Member

Choose a reason for hiding this comment

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

no need for React. prefix

@matthewdeutsch matthewdeutsch linked an issue Apr 13, 2021 that may be closed by this pull request
@devongovett devongovett merged commit b916b32 into adobe:main Apr 14, 2021
@devongovett
Copy link
Member

Thank you!!

majornista pushed a commit to majornista/react-spectrum-v3 that referenced this pull request May 19, 2021
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.

Update Tabs API

4 participants