Skip to content

<ion-item-options> in RTL incorrect swiping direction (Ionic4) #14328

Closed

Description

@ghybs

Ionic version: (check one with "x")
(For Ionic 1.x issues, please use https://github.com/ionic-team/ionic-v1)
[ ] 2.x
[ ] 3.x
[x] 4.x

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request

Current behavior:

When RTL (CSS rule direction: rtl) is applied on the page, <ion-item-options> buttons are correctly placed on the left when side is set to "end" (default) and right for "start".
However, the child <ion-item-option> item is not allowed to swipe to the correct direction:

  • on "end" (i.e. placed on the left), the item can still swipe only from right to left, like in LTR.
  • on "start" (i.e. placed on the right), the item can still swipe only from left to right, like in LTR.

You have to swipe the entire item length to be able to see the buttons (which is impossible to achieve on a real device).

Expected behavior:

Swiping direction should be reversed in RTL

Steps to reproduce:

  1. Try to swipe one of the items that has sliding options (as written in the label).
  2. The swipe direction is incorrect regarding the buttons position and RTL.
  3. The buttons appear only after you swipe the entire item length, so they are correctly placed in respect to RTL, but swiping direction is incorrect.

Related code:

http://plnkr.co/edit/KRaxNqZdrO46BpNdbzsR?p=preview

body {
   direction: rtl;
}
<ion-item-sliding>
  <ion-item>
    <ion-label>Item with "start" and "end" options</ion-label>
  </ion-item>
  <ion-item-options side="start">
    <ion-item-option onClick="favorite(item)">Favorite</ion-item-option>
    <ion-item-option color="danger" onClick="share(item)">Share</ion-item-option>
  </ion-item-options>

  <ion-item-options side="end">
    <ion-item-option onClick="unread(item)">Unread</ion-item-option>
  </ion-item-options>
</ion-item-sliding>

Other information:

Follows issue #14293

Activity

  1. ghybs commented on Apr 15, 2018

    @ghybs
    ContributorAuthor

    Hi,

    FWIW, it looks like the <ion-item-sliding> swiping direction does change with the HTML attribute dir="rtl", but somehow the <ion-item-options> button position and the swiping direction do not match…

    So with current version there is somehow a workaround, by:

    • setting RTL on the page <html dir="rtl">
    • setting LTR on the the <ion-item-sliding dir="ltr">
    • setting RTL on the child <ion-item dir="rtl">'s (possibly on the <ion-item-option dir="rtl">'s as well?)

    Example: http://plnkr.co/edit/FTL6aGT1aJiPBgXciCxW?p=preview

  2. manucorporat commented on Apr 15, 2018

    @manucorporat
    Contributor

    @ghybs unfortunately we can't support:

    body {
       direction: rtl;
    }
    

    because there are not a CSS pseudo selector we can use:
    https://caniuse.com/#feat=css-dir-pseudo

    <html dir="rtl">
    

    is the only possible solution until browser vendors implement the :dir() psudo selector

  3. ghybs commented on Apr 15, 2018

    @ghybs
    ContributorAuthor

    Hi,

    Thank you for your message.

    While it is true that my original message used the CSS rule for setting RTL direction, there is still an issue when using the dir="rtl" HTML attribute:
    http://plnkr.co/edit/mp5X72AHkEDSgQRicW6v?p=preview

    <html dir="rtl">
    <body>

    Instead of having the buttons on the correct position (i.e. reversed compared to LTR) but swiping incorrect (i.e. same as in LTR), the situation is now the opposite: swiping is indeed correct (i.e. reversed compared to LTR), but buttons are in their original position (i.e. same as in LTR)…

    As shown in my message above, we can somehow workaround this inconsistency my "manually" playing with LTR and RTL values on the <html dir="rtl">, <ion-item-sliding dir="ltr"> and <ion-item dir="rtl"> (http://plnkr.co/edit/FTL6aGT1aJiPBgXciCxW?p=preview), but I feel you would not like having developers resorting to such strange technique when advertising full RTL support…

  4. ghybs commented on Apr 15, 2018

    @ghybs
    ContributorAuthor

    BTW setting the RTL value on the <body> instead of <html> tag gives the same situation as originally reported: buttons are in expected position (i.e. on the right for side="start" and on the left for side="end", but swiping direction is the same as is LTR):
    http://plnkr.co/edit/AI1bloEY1KqDQwtdW8oS?p=preview

    <html>
    <body dir="rtl">
  5. brandyscarney commented on Apr 16, 2018

    @brandyscarney
    Member

    @AmitMY Any input on this? 🙂

  6. AmitMY commented on Apr 16, 2018

    @AmitMY
    Contributor

    I discussed this with @manucorporat in greater length, but basically, yes, the current behavior has a problem, should rework that. The old PR fixed the swiping direction, but not buttons positions, and for that we still have #12154 (it's also in the RTL shared doc)

  7. self-assigned this
    on Apr 27, 2018
  8. added
    package: core
    type: bug
    and removed on Dec 3, 2018
  9. paulstelzer commented on Jan 19, 2019

    @paulstelzer
    Contributor

    I close this here because @abennouna has a nice list of RTL issues here -> #17012

  10. ionitron-bot commented on Feb 18, 2019

    @ionitron-bot

    Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

  11. locked and limited conversation to collaborators on Feb 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

package: coretype: bug

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions