File tree 1 file changed +16
-1
lines changed
packages/canonical-bridge/src/views
1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -41,12 +41,27 @@ export const CanonicalBridge = (props: CanonicalBridgeProps) => {
41
41
42
42
useEffect ( ( ) => {
43
43
if ( typeof document !== 'undefined' ) {
44
- const inputElement = document . querySelector ( '.bccb-widget-transfer-input' )
44
+ const inputElement = document . querySelector ( '.bccb-widget-transfer-input' ) as HTMLInputElement | null
45
45
if ( inputElement ) {
46
46
inputElement . setAttribute ( 'pattern' , '^[0-9]*[.,]?[0-9]*$' )
47
+
48
+ const handlePaste = ( e : ClipboardEvent ) => {
49
+ const pastedValue = e ?. clipboardData ?. getData ( 'Text' )
50
+
51
+ if ( ! pastedValue || ! / ^ [ 0 - 9 ] * [ . , ] ? [ 0 - 9 ] * $ / . test ( pastedValue ) ) {
52
+ e . preventDefault ( )
53
+ }
54
+ }
55
+
56
+ inputElement . addEventListener ( 'paste' , handlePaste )
47
57
refresh ( )
58
+
59
+ return ( ) => {
60
+ inputElement . removeEventListener ( 'paste' , handlePaste )
61
+ }
48
62
}
49
63
}
64
+ return undefined
50
65
} , [ refresh ] )
51
66
52
67
const config = useMemo < ICanonicalBridgeConfig > (
You can’t perform that action at this time.
0 commit comments