Rendering in a table issue: widget is rendered as a div with no structure
- Langage dominant
- Common Lisp
- Étoiles
- 101
- Forks
- 12
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
Hi,
I have an issue rendering a widget as a row inside a table. It is rendered inside a `div` and it doesn't respect the markup of my render function.
This reminds me of a fix we implemented some months ago. We corrected `get-html-tag` for it to consult Spinneret and return a `:tr` or a `:td` if we are inside a table, and a `:div` otherwise.
I start like this:
```
(defmethod render ((widget book-widget))
(let ((book (book widget)))
(with-html
(:td (bookshops.models:title book))
(:td (bookshops.models:authors book))
(:td (bookshops.models:price book) "€")
(:td (format nil "x ~a" (bookshops.models:quantity book)))
(:td (with-html-form (:POST (lambda (&key &allow-other-keys)
(add-book widget)))
(:input :type "submit"
:title "Add 1 copy to your stock"
:value "+ 1"))))))
```
`add-book` updates the widget:
```
(defun add-book (book-widget)
"Add one copy to the default place."
(let ((book (book book-widget)))
(bookshops.models:add-to *place*
book)
(update book-widget)))
```
I render the table inside my main widget:
```
(:table
(:tbody
(loop for elt in (books widget)
do (with-html
(:tr (render elt))))))))
```
and it displays the table correctly. When I click on the +1 button, a new widget is inserted above the widget that was clicked, inside the `tr`, it is rendered as a div and it doesn't contain any `:td`, only the plain text title + author + price + quantity concatenated.
```
<-- tr of first page load
// the thing appearing after the click:
// the widget that was clicked:
Le langage lisp
Cayrol
```

1. tracing my render function: it is called.
2. logging `get-html-tag` and thus `spinneret:get-html-path`: the path is NIL (??)
3. I tried rendering my widget with an enclosing `:tr`: it doesn't change that the path is NIL and the rendered html as no `td` but all the fields as text.
---
Do you have any pointers or best practices to share?
ps: [code](https://github.com/vindarel/cl-bookshops/blob/master/src/web/blocks.lisp)
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Le problème se situe dans la logique de rendu de reblocks lorsqu’un widget est mis à jour à l’intérieur d’un tableau. Examinez la fonction get-html-tag et spinneret:get-html-path pour comprendre pourquoi le chemin vaut NIL. La méthode render de book-widget renvoie des éléments :td, mais après une mise à jour, le widget est rendu comme un div. Vérifiez comment reblocks gère les mises à jour des widgets et le contexte HTML. Le code se trouve dans src/web/blocks.lisp. Testez en ajoutant un widget à un tableau et en cliquant sur le bouton +1.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- html
- Domaine
- frontend, web-dev
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 45/100