GeekyAnts / NativeBase

Mobile-first, accessible components for React Native & Web to build consistent UI across Android, iOS and Web.
https://nativebase.io/
MIT License
20.21k stars 2.39k forks source link

[Regression] `Button` `_text` property completely overrides `_text` property defined in the themed button component #5436

Open Swiftwork opened 2 years ago

Swiftwork commented 2 years ago

Description

The component's _text property should merge and override with the one defined in the theme rather than resetting it.

CodeSandbox/Snack link

https://snack.expo.dev/@swiftwork/button-theme-override

Steps to reproduce

  1. Extend the Button component theme
    const theme = extendTheme({
    components: {
    Button: {
      variants: {
        outline: ({colorScheme}) => ({
          _dark: { _text: { color: `${colorScheme}.200` } },
        }),
      },
    },
    },
    config: {
    initialColorMode: 'dark',
    },
    });
  2. Set an unrelated property in the button's _text property
    <Button _text={{textTransform: 'uppercase' }}>Hello There!</Button>
  3. Observe text color not being changed

NativeBase Version

3.4

Platform

Other Platform

No response

Additional Information

Discord discussion https://discord.com/channels/785491682719301643/1025200721072763042/1025396759041687662

Swiftwork commented 2 years ago

Hmm, realized a mistake in the snack, it now seems to be working. I'll do some more digging and if it is not reproducible outside of my code I'll close this issue.

Swiftwork commented 2 years ago

Rewrote the issue to address the actual change between v3.3 and v3.4. There seems to be a regression regarding how nested properties written on components interact with the theme properties. It used to merge, but now seems to reset and override. Check out the snack to get a better understanding.

ankit-tailor commented 2 years ago

Hi @Swiftwork, Thanks for reporting the issue. We'll look into it.