Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#564 bug at new snippet selection #566

Merged
merged 1 commit into from
Nov 12, 2024
Merged

Conversation

vlad1slove1
Copy link
Contributor

@vlad1slove1 vlad1slove1 commented Nov 11, 2024

BUG #564

  • added java language to i18next locales to fix java icon appearance
  • fixed handleInputLng() function at NewSnippet.jsx

while testing the code, i've discovered a new bug at modal on new snippet selection:

inside modal we cannot select "java" option because of this block:

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

when we type "java" the filteredOptions will filter all occurences which starts from "java". It means option "javascript" has been included. Array will become like this:

const filteredOptions = ['javascript', 'java'];
// filteredOptions.slice(0, 1) = 'javascript';
setSelectedLng('javascript');

at my variant selection work by next case:

const filteredOptions = supportedLanguages.filter((language) =>
    language.toLowerCase().startsWith(lowerInput),
);

// select exact match, if non existed then select first
const selectedLanguage =
    filteredOptions.find(
        (language) => language.toLowerCase() === lowerInput,
    ) || filteredOptions[0];

setSelectedLng([selectedLanguage]);
icons_fixed.mp4
java_option_bug.mp4
java_option_bug_fixed.mp4

@vlad1slove1 vlad1slove1 changed the title bug-564 #bug-564 Nov 11, 2024
@vlad1slove1 vlad1slove1 changed the title #bug-564 #564-bug at new snippet selection Nov 11, 2024
@vlad1slove1 vlad1slove1 changed the title #564-bug at new snippet selection #564 bug at new snippet selection Nov 11, 2024
@dzencot dzencot merged commit 226ae9b into hexlet-rus:main Nov 12, 2024
@vlad1slove1 vlad1slove1 deleted the bug-564 branch November 13, 2024 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants