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

docs: menuPortalZIndex docs improvements #2484

Merged
merged 9 commits into from
Apr 13, 2023

Conversation

kark
Copy link
Contributor

@kark kark commented Apr 5, 2023

Summary

closes #2477

Perhaps there is some misunderstanding on my part and those improvements are not needed at all.

@changeset-bot
Copy link

changeset-bot bot commented Apr 5, 2023

🦋 Changeset detected

Latest commit: e82b573

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 93 packages
Name Type
@commercetools-uikit/async-creatable-select-field Patch
@commercetools-uikit/async-creatable-select-input Patch
@commercetools-uikit/selectable-search-input Patch
@commercetools-uikit/creatable-select-field Patch
@commercetools-uikit/creatable-select-input Patch
@commercetools-uikit/search-select-field Patch
@commercetools-uikit/search-select-input Patch
@commercetools-uikit/async-select-field Patch
@commercetools-uikit/async-select-input Patch
@commercetools-uikit/select-field Patch
@commercetools-uikit/select-input Patch
@commercetools-uikit/select-utils Patch
@commercetools-uikit/money-field Patch
@commercetools-uikit/money-input Patch
@commercetools-uikit/fields Patch
@commercetools-uikit/inputs Patch
@commercetools-frontend/ui-kit Patch
@commercetools-uikit/data-table-manager Patch
@commercetools-uikit/pagination Patch
@commercetools-uikit/checkbox-input Patch
@commercetools-uikit/date-input Patch
@commercetools-uikit/date-range-input Patch
@commercetools-uikit/date-time-input Patch
@commercetools-uikit/localized-money-input Patch
@commercetools-uikit/date-field Patch
@commercetools-uikit/date-range-field Patch
@commercetools-uikit/date-time-field Patch
@commercetools-uikit/design-system Patch
@commercetools-uikit/calendar-time-utils Patch
@commercetools-uikit/calendar-utils Patch
@commercetools-uikit/hooks Patch
@commercetools-uikit/i18n Patch
@commercetools-uikit/localized-utils Patch
@commercetools-uikit/utils Patch
@commercetools-uikit/accessible-hidden Patch
@commercetools-uikit/avatar Patch
@commercetools-uikit/card Patch
@commercetools-uikit/collapsible-motion Patch
@commercetools-uikit/collapsible-panel Patch
@commercetools-uikit/collapsible Patch
@commercetools-uikit/constraints Patch
@commercetools-uikit/data-table Patch
@commercetools-uikit/field-errors Patch
@commercetools-uikit/field-label Patch
@commercetools-uikit/grid Patch
@commercetools-uikit/icons Patch
@commercetools-uikit/label Patch
@commercetools-uikit/link Patch
@commercetools-uikit/loading-spinner Patch
@commercetools-uikit/messages Patch
@commercetools-uikit/notifications Patch
@commercetools-uikit/primary-action-dropdown Patch
@commercetools-uikit/stamp Patch
@commercetools-uikit/tag Patch
@commercetools-uikit/text Patch
@commercetools-uikit/tooltip Patch
@commercetools-uikit/view-switcher Patch
@commercetools-uikit/accessible-button Patch
@commercetools-uikit/flat-button Patch
@commercetools-uikit/icon-button Patch
@commercetools-uikit/link-button Patch
@commercetools-uikit/primary-button Patch
@commercetools-uikit/secondary-button Patch
@commercetools-uikit/secondary-icon-button Patch
@commercetools-uikit/localized-multiline-text-field Patch
@commercetools-uikit/localized-text-field Patch
@commercetools-uikit/multiline-text-field Patch
@commercetools-uikit/number-field Patch
@commercetools-uikit/password-field Patch
@commercetools-uikit/radio-field Patch
@commercetools-uikit/text-field Patch
@commercetools-uikit/time-field Patch
@commercetools-uikit/input-utils Patch
@commercetools-uikit/localized-multiline-text-input Patch
@commercetools-uikit/localized-rich-text-input Patch
@commercetools-uikit/localized-text-input Patch
@commercetools-uikit/multiline-text-input Patch
@commercetools-uikit/number-input Patch
@commercetools-uikit/password-input Patch
@commercetools-uikit/radio-input Patch
@commercetools-uikit/rich-text-input Patch
@commercetools-uikit/rich-text-utils Patch
@commercetools-uikit/search-text-input Patch
@commercetools-uikit/text-input Patch
@commercetools-uikit/time-input Patch
@commercetools-uikit/toggle-input Patch
@commercetools-uikit/spacings-inline Patch
@commercetools-uikit/spacings-inset-squish Patch
@commercetools-uikit/spacings-inset Patch
@commercetools-uikit/spacings-stack Patch
@commercetools-uikit/buttons Patch
@commercetools-uikit/spacings Patch
visual-testing-app Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Apr 5, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ui-kit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 13, 2023 9:38am

Comment on lines 159 to 194
// this IIFE is only to make the `menuPortalTarget` knob show up after `menuPortalZIndex`
{...(() => {
const menuPortalTarget = select(
'menuPortalTarget',
['undefined', 'document.body'],
'undefined'
);
return {
menuPortalTarget:
getMenuPortalTargetValue(menuPortalTarget),
};
})()}
/>
{/* this IIFE is only to make the `menuPortalZIndex-show-neighbouring-stacking-context` knob show up last on the list */}
{(() => {
const isActive = boolean(
'menuPortalZIndex-show-neighbouring-stacking-context',
false
);
return (
isActive && (
<div
style={{
width: '300px',
height: '50px',
position: 'relative',
zIndex: 2,
}}
>
<Card theme="dark">
Stacking context with <code>z-index: 2</code>
</Card>
</div>
)
);
})()}
Copy link
Contributor Author

@kark kark Apr 5, 2023

Choose a reason for hiding this comment

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

I wanted to keep those knobs close to each other, I don’t know any other way of providing certain order of knobs. This is the way I thought of.

Also, would you like me to copy this implementation in all other stories where we test components that have this prop?

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 It will also be helpful in other stories.

@@ -76,7 +76,7 @@ export default Example;
| `hasWarning` | `boolean` | | | Indicates the input field has a warning |
| `maxMenuHeight` | `AsyncCreatableProps['maxMenuHeight']` | | | Maximum height of the menu before scrolling&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
| `menuPortalTarget` | `AsyncCreatableProps['menuPortalTarget']` | | | Dom element to portal the select menu to&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
| `menuPortalZIndex` | `number` | | | z-index value for the menu portal |
| `menuPortalZIndex` | `number` | | | z-index value for the menu portal&#xA;<br>&#xA;Use in conjunction with `menuPortalTarget` |
Copy link
Contributor Author

@kark kark Apr 5, 2023

Choose a reason for hiding this comment

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

I am not adding a changeset as this PR is mainly updating READMEs and a story(ies).

@kark kark force-pushed the kk-menu-portal-z-index-docs-improvements branch from 12521d9 to 620e115 Compare April 5, 2023 11:32
@kark kark requested a review from a team April 5, 2023 12:00
@Rhotimee
Copy link
Contributor

Rhotimee commented Apr 5, 2023

Nice work @kark. What do you think about warning the user when menuPortalZIndex is used without menuPortalTarget?

@kark
Copy link
Contributor Author

kark commented Apr 5, 2023

Nice work @kark. What do you think about warning the user when menuPortalZIndex is used without menuPortalTarget?

Thanks, yes, I think it makes sense to me. I'm a little concerned that this might blow up in several places in the MC-FE 😅 But unless anyone is strongly against, let's go for it and try to fix all the occurrences in the MC.

@Rhotimee
Copy link
Contributor

Rhotimee commented Apr 5, 2023

Thanks, yes, I think it makes sense to me. I'm a little concerned that this might blow up in several places in the MC-FE 😅 But unless anyone is strongly against, let's go for it and try to fix all the occurrences in the MC.

It will only blow up if menuPortalTarget isn't used which means, the zIndex wasn't working properly anyway.
Let's get other opinions though.

@kark
Copy link
Contributor Author

kark commented Apr 6, 2023

It will only blow up if menuPortalTarget isn't used which means, the zIndex wasn't working properly anyway. Let's get other opinions though.

Thanks, good point👍

I added the warnings here but now I think we shouldn’t do that.

For some reason we pass menuPortalZIndex: 1 in defaultProps for all of those components without passing menuPortalTarget. Now we must also provide menuPortalTarget, otherwise our tests fail. I’m not sure but I think this is technically a breaking change as menuPortalZIndex will start to take effect in all the components. And if we delete menuPortalZIndex from defaultProps I guess it is also a breaking change, because client code may already be relying on that value.

@kark
Copy link
Contributor Author

kark commented Apr 13, 2023

I added the warnings here but now I think we shouldn’t do that.

For some reason we pass menuPortalZIndex: 1 in defaultProps for all of those components without passing menuPortalTarget. Now we must also provide menuPortalTarget, otherwise our tests fail. I’m not sure but I think this is technically a breaking change as menuPortalZIndex will start to take effect in all the components. And if we delete menuPortalZIndex from defaultProps I guess it is also a breaking change, because client code may already be relying on that value.

During the discussion yesterday we decided to keep the warning, but exclude menuPortalZIndex: 1 in the if statement's condition

I think this is ready for review now.

Copy link
Member

@emmenko emmenko left a comment

Choose a reason for hiding this comment

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

Thanks a lot @kark for working on it and improving the developer experience 🤗

packages/components/inputs/select-utils/src/warning.ts Outdated Show resolved Hide resolved
Copy link
Member

@emmenko emmenko left a comment

Choose a reason for hiding this comment

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

💯

Copy link
Contributor

@CarlosCortizasCT CarlosCortizasCT left a comment

Choose a reason for hiding this comment

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

Super! 💪

@kark kark merged commit 75da6b8 into main Apr 13, 2023
@kark kark deleted the kk-menu-portal-z-index-docs-improvements branch April 13, 2023 11:03
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.

SelectableSearchInput menuPortalZIndex not being applied properly
4 participants