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

Handling Dropdown content resize #70

Merged
merged 11 commits into from
May 23, 2019
Merged

Conversation

kamilmateusiak
Copy link
Contributor

@kamilmateusiak kamilmateusiak commented May 21, 2019

dropdown-resize

We noticed the issue in Dropdown component. When the number of dropdown list items changes or items are removed on click (screen) Dropdown is not updating its position. Dynamic content of dropdown could also trigger this bug.
We decided to listen on Dropdown content wrapper resize to properly handle those cases.

References:

Also I added props for custom keycodes setup and autofocus first item on creating component and list items count change (filtering)

@@ -111,6 +94,38 @@ class Switch extends React.PureComponent {
}
}

export default React.forwardRef((props, ref) => (
<Switch innerRef={ref} {...props} />
const basePropTypes = {
Copy link
Contributor Author

@kamilmateusiak kamilmateusiak May 21, 2019

Choose a reason for hiding this comment

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

@dprzybylek small refactor to make default props and prop types of Switch visible in the docs
We should avoid defining those as static properties on a component class.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok 👍

SwitchComponent.propTypes = {
...basePropTypes,
innerRef: PropTypes.instanceOf(
typeof Element === 'undefined' ? () => {} : Element
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dprzybylek take a look at #43
We need to figure out a better way to avoid SSR issues.

@@ -141,7 +141,8 @@
"react-day-picker": "^7.2.4",
"react-material-icon-svg": "1.7.0",
"react-popper": "^1.3.3",
"react-transition-group": "^2.4.0"
"react-transition-group": "^2.4.0",
"resize-observer-polyfill": "^1.5.1"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kamilmateusiak kamilmateusiak changed the base branch from master to develop May 23, 2019 09:30
super(props);

this.state = {
focusedElement: (props.items[0] && props.items[0].itemId) || 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.

autofocus first item on component create

@@ -111,6 +94,38 @@ class Switch extends React.PureComponent {
}
}

export default React.forwardRef((props, ref) => (
<Switch innerRef={ref} {...props} />
const basePropTypes = {
Copy link
Contributor

Choose a reason for hiding this comment

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

ok 👍

@@ -34,7 +34,7 @@ exports[`Archives | Components | FiltersMenu renders correctly 1`] = `
/>
}
isDisabled={false}
isFocused={false}
isFocused={true}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, so since now dropdown is default focused?
btw Archives | Components | FiltersMenu this test should have another name ;)
and we should avoid renders correctly tests

Copy link
Contributor Author

@kamilmateusiak kamilmateusiak May 23, 2019

Choose a reason for hiding this comment

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

it's related to autofocus feature, this is the first available dropdown list item (not disabled).
I will change test name :P shame on me

src/components/Dropdown/Dropdown.js Outdated Show resolved Hide resolved
className: PropTypes.string,
defaultFocusedItemId: PropTypes.oneOfType([
Copy link
Contributor

Choose a reason for hiding this comment

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

Where this prop is used? I can't find it in the code.

Copy link
Contributor Author

@kamilmateusiak kamilmateusiak May 23, 2019

Choose a reason for hiding this comment

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

leftover, good catch :)

@kamilmateusiak kamilmateusiak merged commit 4bbe7f3 into develop May 23, 2019
@quarties quarties deleted the feature/dropdown-resize branch May 28, 2019 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants