Skip to content

Shadow Appears on Disabled, Selected Flat Chip When Rendered Next to Outlined Chip in Same Row #4457

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

Closed
ttrvdw opened this issue Jul 18, 2024 · 6 comments
Assignees

Comments

@ttrvdw
Copy link

ttrvdw commented Jul 18, 2024

Current behaviour

I'm rendering chip 1, an outlined chip that is not selected and not disabled in the same row as chip 2, a flat chip that is selected and disabled. Chip 2 is showing a shade at the bottom of the element.
image

The issue seems to only arise when putting chips 1 and 2 in the same row, stacking vertically results in the expected rendering:
image

Expected behaviour

Chip 1: outlined, not selected, not disabled
Chip 2: flat, selected, disabled
Putting Chip 1 and Chip 2 in the same row gives two chips of the same height, where Chip 2 does not have a shade at the bottom.

How to reproduce?

import React from 'react';
import {StyleSheet, View} from 'react-native';
import {Chip} from 'react-native-paper';

const Demo = () => {
  return (
    <View style={styles.container}>
      <Chip mode="outlined" selected={false} disabled={false}>
        Not selected, enabled
      </Chip>
      <Chip mode="flat" selected={true} disabled={true}>
        Selected, disabled
      </Chip>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flexDirection: 'row',
  },
});

export default Demo;

Preview

image

What have you tried so far?

Explicitly setting the height of the chips to 32 solves the problem. I suspect a problem with two different overlays (disabled and selected) with different flex properties.

Edit: The above proposed fix still causes problems with chips that have an onClose handler, as the cross icon increases the size of the chip.

Your Environment

software version
ios 17.5
react-native 0.74.3
react-native-paper 5.12.3
node 20.12.2
yarn 1.22.22
expo sdk 0.10.11
@ttrvdw ttrvdw added the bug label Jul 18, 2024
@ttrvdw
Copy link
Author

ttrvdw commented Jul 19, 2024

After playing around some more, the issue seems to lie in the mode={'flat'}. The click target has a smaller height than the height of the blue color applied to the chip. This happens only when the chip is placed in a row together with an element with a larger height.

@ttrvdw
Copy link
Author

ttrvdw commented Jul 19, 2024

image

Video illustrating the click target size is not correct:

Simulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-07-19.at.12.10.32.mp4

The issue is also showing when the chip is enabled. Root cause lies in the size changing for mode={'flat'} if it's in a row with a larger component.

@kamilkedzierski
Copy link
Member

Hey @ttrvdw! 👋 I've just created a PR that resolves the shadow issue. However, I wasn't able to reproduce the problem with the Chip changing size when selected. Could you please provide a code snippet demonstrating this issue? 🙏

@ttrvdw
Copy link
Author

ttrvdw commented Jul 24, 2024

Hey @ttrvdw! 👋 I've just created a PR that resolves the shadow issue. However, I wasn't able to reproduce the problem with the Chip changing size when selected. Could you please provide a code snippet demonstrating this issue? 🙏

Thanks for taking a deeper look into this issue!

Apologies for the confusion around this. Our setup is such that a we switch between flat and outlined when toggling from unselected to selected. A more accurate description of the issue is that the size of a chip seems to change in my setup when switching from flat to outlined and vice versa. Hope that clarifies the issue.

@kamilkedzierski
Copy link
Member

I got you! I gave it another go and toggled between flat and outlined modes, but I couldn't reproduce the issue.

Check out this Expo snack to see how I tested it: Expo Snack Link. I also ran it locally with the same versions of react-native and react-native-paper.

If there's anything I should tweak in my code to trigger the issue, just let me know!

@lukewalczak
Copy link
Member

The fix from mentioned PR was released in 5.13.4 – if the issue still occurs please ping us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants