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

Fix: updated regex validation for color theme designer input field #33148

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,13 @@ export const Form: React.FC = () => {
},
});
}, [dispatch, debounceKeyColor, debounceHueTorsion, debounceVibrancy]);

const generateHexColor = (e: React.ChangeEvent<HTMLInputElement>) =>
'#' + e.target.value.replace(/\W/g, '').toUpperCase();

const generateHexColor = (e: React.ChangeEvent<HTMLInputElement>): string => {
return '#' + e.target.value
.replace(/[^0-9A-F]/gi, '')
.toUpperCase();
};

const handleKeyColorChange = (e: React.ChangeEvent<HTMLInputElement>) => {
// check if the newly inputted hex code has a #
const newHexColor = generateHexColor(e);
Expand Down
Loading