Support » Plugin: Contact Form 7 » Jumping textarea (message) when using grammarly extension

  • Hi,

    I have a trouble with textarea field (message) when using grammarly extension when using on browser. The field is jumping down and up.

    Have any of you have this problem?

    • This topic was modified 3 years, 4 months ago by momentswithme.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Hi @momentswithme,
    I was able to disable the Grammarly by adding attr data-gramm_editor="false" in the text area. Since, I didn’t find any filter, I had to override the function like below:

    if(class_exists('WPCF7')){
    	remove_action('wpcf7_init', 'wpcf7_add_form_tag_textarea', 10);
    	add_action('wpcf7_init', 'wpcf7_add_form_tag_textarea_customized', 11);
    }
    
    function wpcf7_add_form_tag_textarea_customized(){
    	wpcf7_add_form_tag( array( 'textarea', 'textarea*' ),
    		'wpcf7_textarea_form_tag_handler_customized', array( 'name-attr' => true ) );
    }
    
    function wpcf7_textarea_form_tag_handler_customized( $tag ) {
    	if ( empty( $tag->name ) ) {
    		return '';
    	}
    
    	$validation_error = wpcf7_get_validation_error( $tag->name );
    
    	$class = wpcf7_form_controls_class( $tag->type );
    
    	if ( $validation_error ) {
    		$class .= ' wpcf7-not-valid';
    	}
    
    	$atts = array();
    
    	$atts['data-gramm_editor'] = "false"; // disable grammerly azizultex
    	$atts['cols'] = $tag->get_cols_option( '40' );
    	$atts['rows'] = $tag->get_rows_option( '10' );
    	$atts['maxlength'] = $tag->get_maxlength_option();
    	$atts['minlength'] = $tag->get_minlength_option();
    
    	if ( $atts['maxlength'] && $atts['minlength'] && $atts['maxlength'] < $atts['minlength'] ) {
    		unset( $atts['maxlength'], $atts['minlength'] );
    	}
    
    	$atts['class'] = $tag->get_class_option( $class );
    	$atts['id'] = $tag->get_id_option();
    	$atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true );
    
    	$atts['autocomplete'] = $tag->get_option( 'autocomplete',
    		'[-0-9a-zA-Z]+', true );
    
    	if ( $tag->has_option( 'readonly' ) ) {
    		$atts['readonly'] = 'readonly';
    	}
    
    	if ( $tag->is_required() ) {
    		$atts['aria-required'] = 'true';
    	}
    
    	$atts['aria-invalid'] = $validation_error ? 'true' : 'false';
    
    	$value = empty( $tag->content )
    		? (string) reset( $tag->values )
    		: $tag->content;
    
    	if ( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) ) {
    		$atts['placeholder'] = $value;
    		$value = '';
    	}
    
    	$value = $tag->get_default_option( $value );
    
    	$value = wpcf7_get_hangover( $tag->name, $value );
    
    	$atts['name'] = $tag->name;
    
    	$atts = wpcf7_format_atts( $atts );
    
    	$html = sprintf(
    		'<span class="wpcf7-form-control-wrap %1$s"><textarea %2$s>%3$s</textarea>%4$s</span>',
    		sanitize_html_class( $tag->name ), $atts,
    		esc_textarea( $value ), $validation_error );
    
    	return $html;
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Jumping textarea (message) when using grammarly extension’ is closed to new replies.