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 the handling of the icon using JavaScript in the slug field #6622

Merged
merged 1 commit into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions assets/icons/internal/lock-open-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 2 additions & 3 deletions assets/js/field-slug.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class Slugger {
*/
appendLockButton() {
this.lockButton = this.field.parentNode.querySelector('button');
this.lockButtonIcon = this.lockButton.querySelector('i');
this.lockButton.addEventListener('click', () => {
if (this.locked) {
let confirmMessage = this.field.dataset.confirmText || null;
Expand All @@ -106,7 +105,7 @@ class Slugger {
*/
unlock() {
this.locked = false;
this.lockButtonIcon.classList.replace('fa-lock', 'fa-lock-open');
this.lockButton.innerHTML = this.lockButton.getAttribute('data-icon-unlocked');
this.field.removeAttribute('readonly');
}

Expand All @@ -115,7 +114,7 @@ class Slugger {
*/
lock() {
this.locked = true;
this.lockButtonIcon.classList.replace('fa-lock-open', 'fa-lock');
this.lockButton.innerHTML = this.lockButton.getAttribute('data-icon-locked');

// Locking it back changes the value either to default value, or recomputes it
if ('' !== this.currentSlug) {
Expand Down
2 changes: 1 addition & 1 deletion public/entrypoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
"field-slug": {
"js": [
"/field-slug.bed171ad.js"
"/field-slug.df11f109.js"
]
},
"field-textarea": {
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"field-collection.js": "field-collection.f685c209.js",
"field-file-upload.js": "field-file-upload.7f9cb952.js",
"field-image.js": "field-image.c338d2ad.js",
"field-slug.js": "field-slug.bed171ad.js",
"field-slug.js": "field-slug.df11f109.js",
"field-textarea.js": "field-textarea.74319bb1.js",
"field-text-editor.css": "field-text-editor.750725ec.css",
"field-text-editor.js": "field-text-editor.cb6de4f5.js",
Expand Down
4 changes: 3 additions & 1 deletion templates/crud/form_theme.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,9 @@

<div class="input-group">
{{ block('form_widget') }}
<button type="button" class="btn">
<button type="button" class="btn"
data-icon-locked="{{ component('ea:Icon', {name: 'internal:lock'})|e('html_attr') }}"
data-icon-unlocked="{{ component('ea:Icon', {name: 'internal:lock-open-solid'})|e('html_attr') }}">
<twig:ea:Icon name="internal:lock" />
</button>
</div>
Expand Down
Loading