react-native-floating-label-input icon indicating copy to clipboard operation
react-native-floating-label-input copied to clipboard

can't set topFocused when using staticLabel={true}

Open louisholley opened this issue 4 years ago • 2 comments

in the docs for staticLabel it says:

"For changing the position of the label with this prop as true, use the customLabelStyles topFocused and leftFocused to adjust the wanted position"

but the implementation is like this:

{staticLabel && (
          <AnimatedText
            onPress={setFocus}
            style={[
              style,
              {
                left: labelStyles?.left
                  ? labelStyles?.left
                  : customLabelStyles.leftFocused
                  ? customLabelStyles.leftFocused
                  : 20,
                top: -(style?.fontSize ? style?.fontSize : 10) / 2,
              },
            ]}
          >
            {label}
          </AnimatedText>
        )}

so setting topFocused doesn't have any effect when using staticLabel={true}

louisholley avatar May 24 '21 16:05 louisholley

Hi @louisholley, yes you are right, but I don't think staticLabel should be used along with topFocused.. I will move the order for the left and top styles to have lower priority than labelStyles like:

{staticLabel && (
          <AnimatedText
            onPress={setFocus}
            style={[
              {
                left: labelStyles?.left
                  ? labelStyles?.left
                  : customLabelStyles.leftFocused
                  ? customLabelStyles.leftFocused
                  : 20,
                top: -(style?.fontSize ? style?.fontSize : 10) / 2,
              },
              style
            ]}
          >
            {label}
          </AnimatedText>
        )}
        
//...

So then the right usage scenario would be something like:

<FloatingLabelInput
    // ...
    labelStyles={{ top: 15, left: 20}}
    />

Cnilton avatar May 24 '21 16:05 Cnilton

@Cnilton sounds ideal man, let me know when you've made the change! thanks a lot

louisholley avatar May 25 '21 08:05 louisholley