File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
src/bundle/Resources/public/admin/js Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change 77 const baseLanguageSelect = doc . querySelector ( BASE_LANGUAGE_SELECT_SELECTOR ) ;
88 const languageSelect = doc . querySelector ( LANGUAGE_SELECT_SELECTOR ) ;
99
10+ // Store the user's last checked state
11+ let userCheckedState ;
1012
1113 const handleLanguageChange = ( ) => {
1214 const translationCheckbox = translatorSelect . closest ( '.ibexa-input--checkbox' ) ;
1315 if ( translationCheckbox ) {
1416 const supportedLanguages = translationCheckbox . getAttribute (
1517 `data-supported-translation-languages-${ translationCheckbox . value } `
1618 ) ;
17- translationCheckbox . disabled = ! (
19+ const shouldBeEnabled = (
20+ baseLanguageSelect . value &&
1821 supportedLanguages . includes ( baseLanguageSelect . value ) &&
1922 supportedLanguages . includes ( languageSelect . value )
2023 ) ;
21- translationCheckbox . checked = ! translationCheckbox . disabled ;
2224
25+ // If checkbox is currently enabled, store its state before potentially disabling it
26+ if ( ! translationCheckbox . disabled ) {
27+ userCheckedState = translationCheckbox . checked ;
28+ }
29+
30+ translationCheckbox . disabled = ! shouldBeEnabled ;
31+
32+ // Restore the user's last checked state, whether it was checked or unchecked
33+ if ( shouldBeEnabled ) {
34+ translationCheckbox . checked = userCheckedState !== undefined ? userCheckedState : true ;
35+ } else {
36+ translationCheckbox . checked = false ;
37+ }
2338 }
2439
2540 const translationSelectWrapper = translatorSelect . closest ( '.ibexa-dropdown' ) ;
You can’t perform that action at this time.
0 commit comments