Skip to content

Commit

Permalink
Merge pull request #566 from vlad1slove1/bug-564
Browse files Browse the repository at this point in the history
#564 bug at new snippet selection
  • Loading branch information
dzencot authored Nov 12, 2024
2 parents 6864d96 + 287d488 commit 226ae9b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
25 changes: 12 additions & 13 deletions frontend/src/components/Modals/NewSnippet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,7 @@ import routes from '../../routes';
import { useAuth, useSnippets } from '../../hooks';
import { snippetName } from '../../utils/validationSchemas';
import { actions as modalActions } from '../../slices/modalSlice.js';
import JavaScriptIcon from '../../assets/images/icons/javascript.svg';
import HtmlIcon from '../../assets/images/icons/html.svg';
import PhpIcon from '../../assets/images/icons/php.svg';
import PythonIcon from '../../assets/images/icons/python.svg';

const icons = new Map()
.set('javascript', JavaScriptIcon)
.set('html', HtmlIcon)
.set('python', PythonIcon)
.set('php', PhpIcon);
import icons from '../../utils/icons';

const generateGuestUserData = () => {
const username = `guest_${faker.string.alphanumeric(5)}`;
Expand Down Expand Up @@ -170,11 +161,19 @@ function NewSnippet({ handleClose, isOpen }) {
};

const handleInputLng = (inputValue) => {
if (inputValue && inputValue.trim() !== '') {
const lowerInput = inputValue.trim().toLowerCase();

if (lowerInput) {
const filteredOptions = supportedLanguages.filter((language) =>
language.toLowerCase().startsWith(inputValue.toLowerCase()),
language.toLowerCase().startsWith(lowerInput),
);
setSelectedLng(filteredOptions.slice(0, 1));

const selectedLanguage =
filteredOptions.find(
(language) => language.toLowerCase() === lowerInput,
) || filteredOptions[0];

setSelectedLng([selectedLanguage]);

if (!once) {
setOnce(true);
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@
"javascript": "JavaScript",
"php": "PHP",
"python": "Python",
"html": "HTML"
"html": "HTML",
"java": "Java"
},
"modals": {
"inDevelopment": {
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@
"javascript": "JavaScript",
"php": "PHP",
"python": "Python",
"html": "HTML"
"html": "HTML",
"java": "Java"
},
"licAgr": {
"city": "город Ульяновск",
Expand Down

0 comments on commit 226ae9b

Please sign in to comment.