Opened 13 years ago
Closed 13 years ago
#3730 closed defect (bug) (fixed)
Use HTML5 'placeholder' attribute for search strings, so AJAX doesn't break
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 1.6 | Priority: | normal |
Severity: | minor | Version: | |
Component: | Core | Keywords: | has-patch 2nd-opinion |
Cc: |
Description
When you are on the forumspage/grouppage/memberpage etc. and klick on "All Topics", in some themes the ajax send the value of the search, too.
So you get no results, because it sends the value "Search Forums..." of the search input, too.
To fix this bug, you can use instead of the javascript the html attribute placeholder.
Here's a working example of the function:
function bp_directory_forums_search_form();
in the bp-forums/bp-forums-template.php
<form action="" method="get" id="search-forums-form"> 1312 <label><input type="text" name="s" id="forums_search" value="<?php echo esc_attr( $search_value ); ?>" onfocus="if (this.value == '<?php echo $default_search_value ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php echo $default_search_value ?>';}" /></label> 1313 <input type="submit" id="forums_search_submit" name="forums_search_submit" value="<?php _e( 'Search', 'buddypress' ); ?>" /> 1314 </form>
You can change it to:
<form action="" method="get" id="search-forums-form"> 1312 <label><input type="text" name="s" id="forums_search" placeholder="<?php echo esc_attr( $search_value ); ?>" /></label> 1313 <input type="submit" id="forums_search_submit" name="forums_search_submit" value="<?php _e( 'Search', 'buddypress' ); ?>" /> 1314 </form>
The form is in this files like the same:
bp-members/bp-members-template.php
bp-groups/bp-groups-template.php
Maybe there are more similar functions.
Buddypress 1.5.1
Wordpress 3.2.1
Change History (7)
#1
@
13 years ago
- Keywords dev-feedback added
- Severity changed from normal to minor
- Summary changed from search value to Use HTML5 'placeholder' attribute for search strings, so AJAX doesn't break
#3
@
13 years ago
Yes, definitely. (If someone feels strongly for not breaking old IE, we could investigate adding a short javascript that adds support for the placeholder attribute). Don't really want to do that, however).
#6
@
13 years ago
- Keywords 2nd-opinion added
OK, I've made the placeholder change.
However, this does not change the behavior originally reported by the OP, which is that clicking All Groups, etc on a group directory respects the terms in the search box. bp-default's JS does this explicitly; see https://buddypress.trac.wordpress.org/browser/trunk/bp-themes/bp-default/_inc/global.js#L602 (line 618). I don't feel strongly about whether this is the "correct" behavior. Thoughts?
I would prefer using placeholder (it would allow us to get rid of some rather ugly code, in addition to fixing bugs like this), but it isn't supported across all browsers (conspicuously, every version of IE).
Because having placeholder text in search boxes is not necessarily a do-or-die feature, I think it would be OK if users of IE and other junky browsers didn't see anything - it would be a progressive enhancement. What do others think?