ui5-webcomponents icon indicating copy to clipboard operation
ui5-webcomponents copied to clipboard

slot seems not working in ui5-table ui5-page

Open MisherLiu opened this issue 5 years ago • 17 comments

Dear UI5 Component Team,

I am using UI5 Component in Vue Framework to do some demos. Here I find the slot is not working well in some component My Vue version is __ "eslint-plugin-vue": "^7.14.0", "vue": "^3.0.0", The eslint will tell me not use 'slot' because it is deprecated, so I replace 'slot' with 'v-slot', ui5-table code snippet like below: vslotColumns

v-slot:columns doesn't work, the render will be blank column header, refer vslotColumns-result

Could you guide on this please? Does this slots in UI5 components work only before Vue version 2.6.0 (this is the version the v-slot released)?

MisherLiu avatar Jul 31 '21 09:07 MisherLiu

@MisherLiu

This is a conflict between slot attribute for vue components and webcomponents. slot is deprecated for vue components, but necessary for webcomponents.

The following eslintrc.js config should work:

module.exports = {
  root: true,
  env: {
    node: true
  },
  'extends': [
    'eslint:recommended',
  ],
  parserOptions: {
    ecmaVersion: 2020
  },
  rules: {
    'vue/no-deprecated-slot-attribute': 'off',
  }
}

Use slot attribute for webcomponents

<div slot="columns">
    <ui5-table-column>
      ....
    </ui5-table-column>
</div>

phipsalabim avatar Aug 01 '21 10:08 phipsalabim

Thanks for your feedback. I still got the error while compling the code. The page is working now, however the css style looks weird. I have to add style to adjust table column and row width.

Thanks BR Misher

MisherLiu avatar Aug 02 '21 04:08 MisherLiu

Hello @MisherLiu to help you with the styles issue, please provide us an environment to look at and investigate - URL to an app, or you can create small Vue 3 app using https://codesandbox.io/

ilhan007 avatar Aug 02 '21 08:08 ilhan007

Ok. Give me some time, I will organize codes. BTW, another issue is while using ui5-page, the height and width is 00, ui5-page cannot be expanded by the content in it. ui5page

MisherLiu avatar Aug 04 '21 04:08 MisherLiu

@MisherLiu Did you set height to the page's container, body, html?

ilhan007 avatar Aug 06 '21 13:08 ilhan007

@MisherLiu

If you are still getting slot validation errors you are probably getting a conflict from vetur. Turning off vetur template validation (eslint-plugin-vue still validates the template) should do the trick

image

phipsalabim avatar Aug 09 '21 07:08 phipsalabim

@MisherLiu Did you set height to the page's container, body, html?

I thought ui5-page would be expand by content, so no height and width are set. But I use it, so I set the height and width now. considering the adpation on different screen or different equipment like mobile/tablet/desktop, how is this ui5-page suitable?

MisherLiu avatar Aug 11 '21 05:08 MisherLiu

@MisherLiu

If you are still getting slot validation errors you are probably getting a conflict from vetur. Turning off vetur template validation (eslint-plugin-vue still validates the template) should do the trick

image

Yes , I turn off this. It works now. However the css looks strange

MisherLiu avatar Aug 11 '21 05:08 MisherLiu

@ilhan007 I have serveral question on some components, do I need create another issue or still use this one?

MisherLiu avatar Aug 11 '21 05:08 MisherLiu

Here @ilhan007 I have several question:

  1. ui5-page must give a fixed height, for example 580px, this is not suitable for adaptiong on different device
  2. ui5-input cannot use v-model have a bi-direction binding
  3. no a component like SAPUI5 form which can contain several label with input in a consistent style , now have to add extra CSS to have a consitent style.
  4. ui5-table have no sort or rowaction properties. Please refer the sandbox here: https://codesandbox.io/s/vigorous-kepler-d03t9?file=/src/components/HelloWorld.vue

MisherLiu avatar Aug 11 '21 08:08 MisherLiu

@MisherLiu

ui5-page must give a fixed height, for example 580px, this is not suitable for adaptiong on different device

in your css set html, body and vue mounting point (usually div with id="app") to height: 100%. There is no need for fixed height

ui5-input cannot use v-model have a bi-direction binding

2 way binding via v-model in vue has never worked for custom webcomponents, only for vue components and native html.

Additionally v-model has undergone breaking changes for vue3. see here

for v-bind to work the ui5-input component would have to emit a 'update:value' event, which is obviously not going to happen since it's very specific to vue3 see here

to get 2 way databinding you can use the following

 <ui5-input
          :value="personDetail.name"
          @input="personDetail.name = $event.target.value">
</ui5-input>

I modified your sandbox example for 2way databinding

If you don't like having to write 2 lines to get 2way databinding you can create your own custom directive to get 2way binding. see here (example uses vue2.x)

You will have to adapt the directive code to vue3 as it introduced breaking changes to the directive api.

phipsalabim avatar Aug 11 '21 16:08 phipsalabim

@MisherLiu

ui5-page must give a fixed height, for example 580px, this is not suitable for adaptiong on different device

in your css set html, body and vue mounting point (usually div with id="app") to height: 100%. There is no need for fixed height The height 100% doesn't work here, please look code in sandbox https://codesandbox.io/s/vigorous-kepler-d03t9?file=/src/App.vue

ui5-input cannot use v-model have a bi-direction binding

2 way binding via v-model in vue has never worked for custom webcomponents, only for vue components and native html.

Additionally v-model has undergone breaking changes for vue3. see here

for v-bind to work the ui5-input component would have to emit a 'update:value' event, which is obviously not going to happen since it's very specific to vue3 see here

to get 2 way databinding you can use the following

 <ui5-input
          :value="personDetail.name"
          @input="personDetail.name = $event.target.value">
</ui5-input>

I modified your sandbox example for 2way databinding

If you don't like having to write 2 lines to get 2way databinding you can create your own custom directive to get 2way binding. see here (example uses vue2.x)

You will have to adapt the directive code to vue3 as it introduced breaking changes to the directive api.

MisherLiu avatar Aug 12 '21 03:08 MisherLiu

@phipsalabim Thanks for your feedback, as you suggest, I use @input to implement the 2way databinding. For the ui5-page, The height 100% doesn't work here, please look code in sandbox https://codesandbox.io/s/vigorous-kepler-d03t9?file=/src/App.vue

MisherLiu avatar Aug 12 '21 03:08 MisherLiu

I also face an issue which the ui5-table No Data property doesn't work in my local code, I cannot reproduce it in sandbox. however the code seems no different local code: <ui5-table id="myTblGrowsOnScroll" ref="myUi5Table" no-data-text="Empty Data"

<ui5-table-column demandPopin="true" popinText="Name" style="width: 10%">
  <span>Name</span>
  <ui5-icon
    id="idSortIcon"
    class="sortIconStyle locateIcon"
    :style="ascIconObject"
    name="sort-ascending"
    show-tooltip
    @click="handleSortClick"
  ></ui5-icon>
  <ui5-icon
    id="idSortDesIcon"
    class="sortIconStyle locateIcon"
    :style="descIconObject"
    name="sort-descending"
    show-tooltip
    @click="handleSortClick"
  ></ui5-icon>
  <ui5-popover id="idSortPopover">
    <div>
      <div>
        <ui5-list>
          <ui5-li icon="sort-ascending" @click="handleAscSort"
            >Sort Ascending</ui5-li
          >
          <ui5-li icon="sort-descending" @click="handleDescSort"
            >Sort Descending</ui5-li
          >
        </ui5-list>
      </div>
    </div>
  </ui5-popover>
</ui5-table-column>

<ui5-table-column demandPopin="true" popinText="Email" style="width: 20%">
  <span>Email</span>
</ui5-table-column>

<ui5-table-column
  demandPopin="true"
  popinText="Birth Date"
  style="width: 20%"
>
  <span>Birth Date</span>
</ui5-table-column>

<ui5-table-column demandPopin="true" popinText="Phone" style="width: 20%">
  <span>Phone</span>
</ui5-table-column>

<ui5-table-column demandPopin="true" popinText="Country" style="width: 20%">
  <span>Country</span>
</ui5-table-column>
<ui5-table-column demandPopin="true" popinText="Actions" style="width: 10%">
</ui5-table-column>


<ui5-table-row
  v-for="item in visibleItems"
  :guid="item.id"
  :key="item.id"
  style="text-align: left"
>
  <template v-for="(value, index) in item" :key="value">
    <ui5-table-cell v-if="index !== 'id'">
      {{ value }}
    </ui5-table-cell>
  </template>
  <ui5-icon
    class="actionIconStyle"
    :guid="item.id"
    style="padding-right: 1rem; padding-left: 1rem"
    name="feeder-arrow"
    show-tooltip
    v-on:click="handleNavTo"
  ></ui5-icon>
  <ui5-icon
    class="actionIconStyle"
    :guid="item.id"
    name="delete"
    show-tooltip
    @click="handleDelete"
  ></ui5-icon>
</ui5-table-row>

MisherLiu avatar Aug 12 '21 04:08 MisherLiu

Hello @MisherLiu,

Are the mentioned issues in your latest comment still relevant?

For the ui5-page, its height is set to 100% which means that the page takes the whole height of it's parent. You have to set height: 100% to both html element and the body or page's container, since the page takes 100% of nothing in other case. For the ui5-table, is the issue still reproducible because I was not able to reproduce it?

Kind Regards, Niya

niyap avatar Jun 06 '22 13:06 niyap

Hello, everyone! The issue has been inactive for 21 days. If there are still questions or comments, please feel free to continue the discussion. Inactive issues will be closed after 7 days!

github-actions[bot] avatar Jul 28 '22 00:07 github-actions[bot]

Hello, everyone! The issue has been inactive for 28 days, so I am closing the issue.

github-actions[bot] avatar Aug 05 '22 00:08 github-actions[bot]