This commit is contained in:
Markos Gogoulos 2025-10-25 19:21:18 +03:00
parent 255d004ecb
commit 7fa605ff6b
2 changed files with 35 additions and 5 deletions

View File

@ -45,10 +45,11 @@ class ProfileSearchBar extends React.PureComponent {
onChange(ev) { onChange(ev) {
this.pendingEvent = ev; this.pendingEvent = ev;
const newValue = ev.target.value || '';
this.setState( this.setState(
{ {
queryVal: ev.target.value || '', queryVal: newValue,
}, },
function () { function () {
if (this.updateTimeout) { if (this.updateTimeout) {
@ -57,8 +58,11 @@ class ProfileSearchBar extends React.PureComponent {
this.pendingEvent = null; this.pendingEvent = null;
// Only trigger search if 3+ characters or empty (to reset)
if ('function' === typeof this.props.onQueryChange) { if ('function' === typeof this.props.onQueryChange) {
this.props.onQueryChange(this.state.queryVal); if (newValue.length >= 3 || newValue.length === 0) {
this.props.onQueryChange(newValue);
}
} }
this.updateTimeout = setTimeout( this.updateTimeout = setTimeout(
@ -137,13 +141,27 @@ class ProfileSearchBar extends React.PureComponent {
} }
render() { render() {
const hasSearchText = this.state.queryVal && this.state.queryVal.length > 0;
if (!this.state.visibleForm) { if (!this.state.visibleForm) {
return ( return (
<div> <div>
<span> <span style={{ position: 'relative' }}>
<CircleIconButton buttonShadow={false} onClick={this.showForm}> <CircleIconButton buttonShadow={false} onClick={this.showForm}>
<i className="material-icons">search</i> <i className="material-icons">search</i>
</CircleIconButton> </CircleIconButton>
{hasSearchText ? (
<span style={{
position: 'absolute',
top: '8px',
right: '8px',
width: '8px',
height: '8px',
borderRadius: '50%',
backgroundColor: 'var(--default-theme-color)',
border: '2px solid white',
}}></span>
) : null}
</span> </span>
</div> </div>
); );
@ -151,10 +169,22 @@ class ProfileSearchBar extends React.PureComponent {
return ( return (
<form method="get" action={LinksContext._currentValue.profile.media} onSubmit={this.onFormSubmit}> <form method="get" action={LinksContext._currentValue.profile.media} onSubmit={this.onFormSubmit}>
<span> <span style={{ position: 'relative' }}>
<CircleIconButton buttonShadow={false}> <CircleIconButton buttonShadow={false}>
<i className="material-icons">search</i> <i className="material-icons">search</i>
</CircleIconButton> </CircleIconButton>
{hasSearchText ? (
<span style={{
position: 'absolute',
top: '8px',
right: '8px',
width: '8px',
height: '8px',
borderRadius: '50%',
backgroundColor: 'var(--default-theme-color)',
border: '2px solid white',
}}></span>
) : null}
</span> </span>
<span> <span>
<input <input

File diff suppressed because one or more lines are too long