Skip to content

Conversation

kvendrik
Copy link
Member

WHY are these changes introduced?

fixes #1125

WHAT is this pull request doing?

Changes the TopBar's contextControl's max-width to width so that when the given element is smaller than the max-width the layout doesn't break

Before
Screen Shot 2019-03-15 at 3 20 38 PM

After
Screen Shot 2019-03-15 at 3 21 41 PM

How to 🎩

Copy-paste this code in playground/Playground.tsx:
import React from 'react';
import {
  ActionList,
  AppProvider,
  Card,
  Frame,
  Label,
  List,
  Navigation,
  TopBar,
} from '@shopify/polaris';

export default class TopBarExample extends React.Component {
  state = {
    userMenuOpen: false,
    searchActive: false,
    searchText: '',
  };

  render() {
    const {
      state,
      handleSearchChange,
      handleSearchResultsDismiss,
      toggleUserMenu,
    } = this;
    const {userMenuOpen, searchText, searchActive} = state;

    const theme = {
      colors: {
        topBar: {
          background: '#357997',
        },
      },
      logo: {
        width: 124,
        topBarSource:
          'https://cdn.shopify.com/s/files/1/0446/6937/files/jaded-pixel-logo-color.svg?6215648040070010999',
        url: 'http://jadedpixel.com',
        accessibilityLabel: 'Jaded Pixel',
      },
    };

    const userMenuMarkup = (
      <TopBar.UserMenu
        actions={[
          {
            items: [{content: 'Back to Shopify', icon: 'arrowLeft'}],
          },
          {
            items: [{content: 'Community forums'}],
          },
        ]}
        name="Dharma"
        detail="Jaded Pixel"
        initials="D"
        open={userMenuOpen}
        onToggle={toggleUserMenu}
      />
    );

    const searchResultsMarkup = (
      <Card>
        <ActionList
          items={[
            {content: 'Shopify help center'},
            {content: 'Community forums'},
          ]}
        />
      </Card>
    );

    const searchFieldMarkup = (
      <TopBar.SearchField
        onChange={handleSearchChange}
        value={searchText}
        placeholder="Search"
      />
    );

    const topBarMarkup = (
      <TopBar
        showNavigationToggle={true}
        userMenu={userMenuMarkup}
        searchResultsVisible={searchActive}
        searchField={searchFieldMarkup}
        searchResults={searchResultsMarkup}
        onSearchResultsDismiss={handleSearchResultsDismiss}
        contextControl={<div />}
        onNavigationToggle={() => {
          console.log('toggle navigation visibility');
        }}
      />
    );

    return (
      <div style={{height: '250px'}}>
        <AppProvider theme={theme}>
          <Frame topBar={topBarMarkup} />
        </AppProvider>
      </div>
    );
  }

  toggleUserMenu = () => {
    this.setState(({userMenuOpen}) => ({userMenuOpen: !userMenuOpen}));
  };

  handleSearchResultsDismiss = () => {
    this.setState(() => {
      return {
        searchActive: false,
        searchText: '',
      };
    });
  };

  handleSearchChange = (value) => {
    this.setState({searchText: value});
    if (value.length > 0) {
      this.setState({searchActive: true});
    } else {
      this.setState({searchActive: false});
    }
  };
}

@BPScott BPScott temporarily deployed to polaris-react-pr-1206 March 15, 2019 19:25 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1206 March 15, 2019 19:26 Inactive
@kvendrik kvendrik requested a review from alex-page March 18, 2019 14:58
@BPScott BPScott temporarily deployed to polaris-react-pr-1206 March 18, 2019 14:58 Inactive
@kvendrik
Copy link
Member Author

Will address this here: #1231

@kvendrik kvendrik closed this Mar 20, 2019
@kvendrik kvendrik deleted the fix/context-control-width branch March 20, 2019 19:59
rcaplanshopify added a commit that referenced this pull request Nov 7, 2022
<!--
  ☝️How to write a good PR title:
- Prefix it with [ComponentName] (if applicable), for example: [Button]
  - Start with a verb, for example: Add, Delete, Improve, Fix…
  - Give as much context as necessary and as little as possible
  - Prefix it with [WIP] while it’s a work in progress
-->

### WHY are these changes introduced?

When a user scrolls to the bottom of the feed, we don't want the rest of
the page to scroll.

Fixes
[#1206](Shopify/merchant-communication#1206)
<!-- link to issue if one exists -->

<!--
  Context about the problem that’s being addressed.
-->

### WHAT is this pull request doing?

<!--
  Summary of the changes committed.

Before / after screenshots are appreciated for UI changes. Make sure to
include alt text that describes the screenshot.

If you include an animated gif showing your change, wrapping it in a
details tag is recommended. Gifs usually autoplay, which can cause
accessibility issues for people reviewing your PR:

    <details>
      <summary>Summary of your gif(s)</summary>
      <img src="..." alt="Description of what the gif shows">
    </details>
-->
This PR adds an optional `captureOverscroll` prop to the `Popover`
component, which gets passed to its `Pane` component. When the prop is
truthy, a class is added to the `Pane` component to capture the
overscroll with this CSS: `overscroll-behavior: contain;`.

The prop is set to `false` by default and will not impact any existing
implementations.

<details>
<summary>Attempts to scroll past the end of the alerts feed do not cause
the page to scroll</summary>


https://user-images.githubusercontent.com/100380574/199125795-b6f90cf6-ce20-4a6e-b801-f658146c2c0e.mp4


</details>
<!-- ℹ️ Delete the following for small / trivial changes -->

### How to 🎩

🖥 [Local development
instructions](https://github.com/Shopify/polaris/blob/main/README.md#local-development)
🗒 [General tophatting
guidelines](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md)
📄 [Changelog
guidelines](https://github.com/Shopify/polaris/blob/main/.github/CONTRIBUTING.md#changelog)

<!--
  Give as much information as needed to experiment with the component
  in the playground.
-->

The updated version of the `Popover` component has been implemented on
[this spin
instance](https://admin.web.polaris-popover-update.rick-caplan.us.spin.dev/store/shop1).

- [ ] Open the alerts feed by clicking on the bell icon
- [ ] Scroll to the bottom of the feed to load the next set of results
- [ ] Scroll to the bottom again and confirm attempts to scroll past the
`No more alerts` message do not cause the page to scroll


### 🎩 checklist

- [ ] Tested on
[mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing)
- [ ] Tested on [multiple
browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers)
- [ ] Tested for
[accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md)
- [ ] Updated the component's `README.md` with documentation changes
- [ ] [Tophatted
documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md)
changes in the style guide
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.

Change TopBar contextControl max-width to width

2 participants