Don't validate hidden fields.

This commit is contained in:
John Livingston 2023-09-26 14:28:06 +02:00
parent 03dfa3de6f
commit 89fb6a7ac6
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC
2 changed files with 33 additions and 27 deletions

View File

@ -7,6 +7,7 @@
* Channel configuration:
* Fix dark mode for buttons.
* Fix buttons margin.
* Don't validate hidden fields.
* Help button on top of the "channels" page.
## 8.0.0

View File

@ -166,6 +166,10 @@ async function vivifyConfigurationChannel (
const validateData: Function = async (channelConfigurationOptions: ChannelConfigurationOptions): Promise<boolean> => {
const botConf = channelConfigurationOptions.bot
const errorFieldSelectors = []
// If !bot.enabled, we don't have to validate these fields:
// The backend will ignore those values.
if (botConf.enabled) {
if (/[^\p{L}\p{N}\p{Z}_-]/u.test(botConf.nickname ?? '')) {
const selector = '#peertube-livechat-bot-nickname'
errorFieldSelectors.push(selector)
@ -200,6 +204,7 @@ async function vivifyConfigurationChannel (
await displayError(selector, message)
}
}
}
if (errorFieldSelectors.length) {
// Set the focus to the first in-error field: