react-native-paper icon indicating copy to clipboard operation
react-native-paper copied to clipboard

Chrome adding blue border around TextInput

Open zelin opened this issue 6 years ago • 13 comments

Environment

"react-native-paper": "^3.9.0", "react-native-web": "~0.11.7", Expo

Description

I am using InputText as


<TextInput
					style={{outlineColor: 'rgba(0,0,0,0)', outlineOffset: 0, outlineStyle: 'none', 
							outlineWidth: 0, backgroundColor: 'white'}}
					theme={this.textValidationTheme(styles)}
					mode="flat"
					ref={o => (this.txtInput = o)}
					label={this.props.label}
					//placeholder={this.state.isFocused ? "" : this.props.label}
					value={this.state.text}
					onFocus={this.onFocus}
					onChangeText={this.onChangeText}
					onBlur={this.onBlur}
					onSubmitEditing={this.onSubmit}
					underlineColor={color.lightGray}
					{...this.props.textInputProps}
				/>

It seems that chrome is adding a default blue outline and no modification in outline settings seem to be working..

Screenshot 2020-05-15 at 5 24 06 AM

zelin avatar May 15 '20 00:05 zelin

here is the walkaround for this. Not sure if we can pass some prop to disable this shadowBox when focused

also here is some old issue about it

jbinda avatar May 21 '20 08:05 jbinda

with react native web you can do:

<TextInput
   style={{outline: "none"}}
/>

timsonater avatar May 27 '20 06:05 timsonater

@zelin can you confirm if above solution works for you ?

jbinda avatar May 27 '20 07:05 jbinda

with react native web you can do:

<TextInput
   style={{outline: "none"}}
/>

it doesn't work

thorxtecnologia avatar May 29 '20 19:05 thorxtecnologia

outlineWidth: 0, worked for me

jcarraway avatar Jun 12 '20 21:06 jcarraway

The focus ring is important for accessibility. If you are removing it, you need to make sure that you're not removing it for keyboard users.

You can use this polyfill to achieve this https://github.com/WICG/focus-visible

satya164 avatar Jun 12 '20 21:06 satya164

This is still not working for me

Jonatthu avatar Jun 18 '20 16:06 Jonatthu

I'm stuck with this issue as well. Any known workarounds?

brandonpearcy avatar Jul 16 '20 23:07 brandonpearcy

I was able to disable the default blue highlight on react-native-paper TextInputs when using react-native-web like so:

App.css

.disable-outline input {
    outline-width: 0;
}

CustomTextInput.tsx

return (
      <div className={'disable-outline'}>
        <TextInput .../>
     </div>
);

brandonpearcy avatar Jul 17 '20 18:07 brandonpearcy

@brandonpearcy I'm having problems with your solution. Do I need a babel plugin or something related to transpile the App.css file? Even on the web it throw an error when i write import './App.css'; .

I have replicated your solution but using instead a package called emotion that allows me to embed global css styles in web format without babel plugins. This is just another workaround.

Here it's a live example on expo snack link

Menganitou avatar Aug 06 '20 14:08 Menganitou

My solution works in a modern create-react-app environment. If I understand correctly, under the hood, CRA is using CSS Modules. More info here: https://create-react-app.dev/docs/adding-a-css-modules-stylesheet/ If you're using a different CSS framework, you'll almost certainly have to adjust the solution. Thanks for sharing a solution using Emotion!

brandonpearcy avatar Aug 11 '20 21:08 brandonpearcy

Screenshot 2020-09-09 at 6 20 12 PM This is not working, please help.

<TextInput
          ref={ref1}
          mode={'outlined'}
          returnKeyType={'next'}
          style={{
            width: '100%',
            ...Platform.select({
              web: {
                outlineWidth: 0
              }
            })
          }}
          {...props}
        />

kamal-mobile-dev avatar Sep 09 '20 12:09 kamal-mobile-dev

from @brandonpearcy

I was able to disable the default blue highlight on react-native-paper TextInputs when using react-native-web like so:

App.css

.disable-outline input {
    outline-width: 0;
}

CustomTextInput.tsx

return (
      <div className={'disable-outline'}>
        <TextInput .../>
     </div>
);

This works. Also, needs to add textarea to the CSS selector too if your TextInput is configured as multiline. e.g. add the following to the css:

.disable-outline textarea {
    outline-width: 0 !important;
}

ahlun avatar Jan 16 '24 15:01 ahlun