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

Block: headers toggle don't work #8

Open
gbdesign2023 opened this issue Jan 31, 2024 · 3 comments
Open

Block: headers toggle don't work #8

gbdesign2023 opened this issue Jan 31, 2024 · 3 comments
Assignees

Comments

@gbdesign2023
Copy link

I have found a small, cosmetic problem:
With the setting "headers: false" in the blueprint, the first line is still displayed as a header in the inline editor. In the dialog editor, the display is correct.

  table:
    label: Tabelle
    type: table
    headers: false
screenshot
@bogdancondorachi bogdancondorachi changed the title headers: false = display in the inline editor is ignored headers toggle don't work on table block Jan 31, 2024
@bogdancondorachi bogdancondorachi changed the title headers toggle don't work on table block Block: headers toggle don't work Jan 31, 2024
@bogdancondorachi bogdancondorachi self-assigned this Jan 31, 2024
@bogdancondorachi
Copy link
Owner

bogdancondorachi commented Jan 31, 2024

@gbdesign2023 This is more like a missing feature. The headers toggle was more of an experimental for your issue and was added only to the field itself (that's why it works on the drawer and not the preview), also the headers would still appear on your page even if headers: false (for blocks).

I'd say right now it's more of an experimental feature as I could not find a nice way to integrate this and I'm not satisfied with it. Here's my current approach:

We're talking about rendering of the table inside the page, my idea was to alter the toTable method as follows:

// get the field blueprint
$blueprint = $field->parent()->blueprint()->field($field->key());
// return the headers field value
$hasHeaders = $blueprint['headers'] ?? true;
// return the first row if true or an empty array if false
$headers = $hasHeaders ? array_shift($rows) : [];

This translates into the following:

  1. The table array is considered rows
  2. If headers: true (default) headers consider the first row as headers
  3. If headers: false headers return empty and the first row returns to the rows array

And the current problems are:

  1. $field->key() returns the field name as lowercase and the headers cannot be returned if the field name is tableSecond for example
  2. I could not find a way to access the block field blueprint as I was in a rush to release this today (that's why it does not work in the block)

At this point, I don't know exactly what would even be the best approach to this feature or if I'm looking at it the right way. Some thoughts regarding this matter would be appreciated.

@gbdesign2023
Copy link
Author

Perhaps I have created an unnecessary complication...
My problem was the missing "thead" in the previous plug-in. I had created a temporary solution for this in the template. Today I have removed this temporary solution and can use "thead" as in your template. If I don't need a "thead", I can solve this individually, for example with a toggle field in the table options. I assume that 99% of other users need a "thead" for tables. Instead of adding new functions, it would be better to concentrate on the core functions of a table.

@bogdancondorachi
Copy link
Owner

This feature is still welcomed but would stay as 'experimental' for now until I can find a good balance on how it works.

@gbdesign2023 Would be nice to share your progress on how you've been able to fix your issue after the last update and some panel shots/video on how are you currently using it. It would help me to better understand it's purpose. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants