fix: username suggestions alignment (#1584)
Co-authored-by: Kyrylo Hudym-Levkovych <kyr.hudym@kyrs-MacBook-Pro.local>
This commit is contained in:
@@ -101,7 +101,7 @@ const UsernameField = (props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const suggestedUsernames = () => (
|
const suggestedUsernames = () => (
|
||||||
<div className={className}>
|
<div className={className} role="listbox">
|
||||||
<span className="text-gray username-suggestion--label">{formatMessage(messages['registration.username.suggestion.label'])}</span>
|
<span className="text-gray username-suggestion--label">{formatMessage(messages['registration.username.suggestion.label'])}</span>
|
||||||
<div className="username-scroll-suggested--form-field">
|
<div className="username-scroll-suggested--form-field">
|
||||||
{usernameSuggestions.map((username, index) => (
|
{usernameSuggestions.map((username, index) => (
|
||||||
@@ -112,7 +112,9 @@ const UsernameField = (props) => {
|
|||||||
className="username-suggestions--chip data-hj-suppress"
|
className="username-suggestions--chip data-hj-suppress"
|
||||||
autoComplete={props.autoComplete}
|
autoComplete={props.autoComplete}
|
||||||
key={`suggestion-${index.toString()}`}
|
key={`suggestion-${index.toString()}`}
|
||||||
|
tabIndex={0}
|
||||||
onClick={(e) => handleSuggestionClick(e, username)}
|
onClick={(e) => handleSuggestionClick(e, username)}
|
||||||
|
role="option"
|
||||||
>
|
>
|
||||||
{username}
|
{username}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -123,7 +125,7 @@ const UsernameField = (props) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (usernameSuggestions.length > 0 && errorMessage && value === ' ') {
|
if (usernameSuggestions.length > 0 && errorMessage && value === ' ') {
|
||||||
className = 'username-suggestions__error';
|
className = 'username-suggestions';
|
||||||
iconButton = <IconButton src={Close} iconAs={Icon} alt="Close" onClick={() => handleUsernameSuggestionClose()} variant="black" size="sm" className="username-suggestions__close__button" />;
|
iconButton = <IconButton src={Close} iconAs={Icon} alt="Close" onClick={() => handleUsernameSuggestionClose()} variant="black" size="sm" className="username-suggestions__close__button" />;
|
||||||
suggestedUsernameDiv = suggestedUsernames();
|
suggestedUsernameDiv = suggestedUsernames();
|
||||||
} else if (usernameSuggestions.length > 0 && value === ' ') {
|
} else if (usernameSuggestions.length > 0 && value === ' ') {
|
||||||
@@ -134,14 +136,15 @@ const UsernameField = (props) => {
|
|||||||
suggestedUsernameDiv = suggestedUsernames();
|
suggestedUsernameDiv = suggestedUsernames();
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<FormGroup
|
<div className="username__form-group-wrapper">
|
||||||
{...props}
|
|
||||||
handleChange={handleOnChange}
|
|
||||||
handleFocus={handleOnFocus}
|
|
||||||
handleBlur={handleOnBlur}
|
|
||||||
>
|
|
||||||
{suggestedUsernameDiv}
|
{suggestedUsernameDiv}
|
||||||
</FormGroup>
|
<FormGroup
|
||||||
|
{...props}
|
||||||
|
handleChange={handleOnChange}
|
||||||
|
handleFocus={handleOnFocus}
|
||||||
|
handleBlur={handleOnBlur}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
import { camelCaseObject } from '@edx/frontend-platform';
|
import { camelCaseObject } from '@edx/frontend-platform';
|
||||||
import { logError, logInfo } from '@edx/frontend-platform/logging';
|
import { logError, logInfo } from '@edx/frontend-platform/logging';
|
||||||
import { call, put, takeEvery } from 'redux-saga/effects';
|
import {
|
||||||
|
call, put, race, take, takeEvery,
|
||||||
|
} from 'redux-saga/effects';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
fetchRealtimeValidationsBegin,
|
fetchRealtimeValidationsBegin,
|
||||||
fetchRealtimeValidationsFailure,
|
fetchRealtimeValidationsFailure,
|
||||||
fetchRealtimeValidationsSuccess,
|
fetchRealtimeValidationsSuccess,
|
||||||
|
REGISTER_CLEAR_USERNAME_SUGGESTIONS,
|
||||||
REGISTER_FORM_VALIDATIONS,
|
REGISTER_FORM_VALIDATIONS,
|
||||||
REGISTER_NEW_USER,
|
REGISTER_NEW_USER,
|
||||||
registerNewUserBegin,
|
registerNewUserBegin,
|
||||||
@@ -41,9 +44,15 @@ export function* handleNewUserRegistration(action) {
|
|||||||
export function* fetchRealtimeValidations(action) {
|
export function* fetchRealtimeValidations(action) {
|
||||||
try {
|
try {
|
||||||
yield put(fetchRealtimeValidationsBegin());
|
yield put(fetchRealtimeValidationsBegin());
|
||||||
const { fieldValidations } = yield call(getFieldsValidations, action.payload.formPayload);
|
|
||||||
|
|
||||||
yield put(fetchRealtimeValidationsSuccess(camelCaseObject(fieldValidations)));
|
const { response } = yield race({
|
||||||
|
response: call(getFieldsValidations, action.payload.formPayload),
|
||||||
|
cancel: take(REGISTER_CLEAR_USERNAME_SUGGESTIONS),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response) {
|
||||||
|
yield put(fetchRealtimeValidationsSuccess(camelCaseObject(response.fieldValidations)));
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.response && e.response.status === 403) {
|
if (e.response && e.response.status === 403) {
|
||||||
yield put(fetchRealtimeValidationsFailure());
|
yield put(fetchRealtimeValidationsFailure());
|
||||||
|
|||||||
@@ -65,10 +65,15 @@
|
|||||||
margin-right: 0.25rem;
|
margin-right: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.username-suggestions {
|
.username__form-group-wrapper {
|
||||||
position: relative;
|
position: relative;
|
||||||
margin-top: -2.5rem;
|
}
|
||||||
margin-left: 15px;
|
|
||||||
|
.username-suggestions {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
padding-left: 15px;
|
||||||
|
z-index: 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
.username-suggestions__close__button {
|
.username-suggestions__close__button {
|
||||||
@@ -76,13 +81,6 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
.username-suggestions__error {
|
|
||||||
position: relative;
|
|
||||||
margin-top: -13.7%;
|
|
||||||
margin-bottom: 11%;
|
|
||||||
margin-left: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.username-scroll-suggested--form-field {
|
.username-scroll-suggested--form-field {
|
||||||
width: 20rem;
|
width: 20rem;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|||||||
Reference in New Issue
Block a user