Repository navigation
fix(rtl): respect dir of ancestor elements throughout components
#31459
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
Merged
+487
−85
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
7af565a
fix(i18n): respect parent rtl setting throughout components
OS-jacobbell 30ad163
lint
OS-jacobbell b0dd608
use `ownerDocument` and convert remaining doc.dir checks
OS-jacobbell 666b48e
Merge branch 'main' into FW-7698
OS-jacobbell 1b50a47
Apply suggestion from @ShaneK
OS-jacobbell 287adf8
add tests
OS-jacobbell 72c055c
updates for col, item, label, title, popover, datetime
OS-jacobbell cc20827
update tests for item-options, item-sliding, popover, and input-shims
OS-jacobbell 24296ab
lint
OS-jacobbell a0d7ce4
chore(): add updated snapshots
Ionitron 3e1b9dd
make tests consistent
OS-jacobbell c2061a2
Merge branch 'main' into FW-7698
OS-jacobbell 3d5e2c4
lint
OS-jacobbell 63509bd
Merge branch 'main' into FW-7698
OS-jacobbell de5e2aa
fix label and title tests
OS-jacobbell de737ee
chore(): add updated snapshots
Ionitron e6c7fce
apply feedback
OS-jacobbell 91e458b
fix test location
OS-jacobbell 5b67b82
improve comment
OS-jacobbell 23d86eb
update popover
OS-jacobbell 6a7a041
chore(): add updated snapshots
Ionitron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import { newSpecPage } from '@stencil/core/testing'; | ||
|
|
||
| import { Col } from '../col'; | ||
|
|
||
| describe('ion-col: rtl', () => { | ||
| const newCol = async (html: string, documentDir?: 'rtl') => { | ||
| const page = await newSpecPage({ components: [Col], html: `<div></div>` }); | ||
| if (documentDir) { | ||
| page.doc.documentElement.setAttribute('dir', documentDir); | ||
| } | ||
| await page.setContent(html); | ||
| return page.body.querySelector('ion-col')!; | ||
| }; | ||
|
|
||
| const cols = (n: number) => `calc(calc(${n} / var(--ion-grid-columns, 12)) * 100%)`; | ||
|
|
||
| const COL_PARAMS = `offset="3" push="2" pull="1"`; | ||
|
|
||
| it('should mirror push and pull when it declares rtl', async () => { | ||
| const col = await newCol(`<ion-col dir="rtl" ${COL_PARAMS}></ion-col>`); | ||
| expect(col.style.right).toBe(cols(2)); | ||
| expect(col.style.left).toBe(cols(1)); | ||
| }); | ||
|
|
||
| it('should mirror push and pull when an ancestor declares rtl', async () => { | ||
| const col = await newCol(`<div dir="rtl"><div><ion-col ${COL_PARAMS}></ion-col></div></div>`); | ||
| expect(col.style.right).toBe(cols(2)); | ||
| expect(col.style.left).toBe(cols(1)); | ||
| }); | ||
|
|
||
| it('should not mirror push and pull when an ancestor declares ltr in an rtl document', async () => { | ||
| const col = await newCol(`<div dir="ltr"><div><ion-col ${COL_PARAMS}></ion-col></div></div>`, 'rtl'); | ||
| expect(col.style.right).toBe(cols(1)); | ||
| expect(col.style.left).toBe(cols(2)); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
core/src/components/item-options/test/item-options.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { newSpecPage } from '@stencil/core/testing'; | ||
|
|
||
| import { ItemOptions } from '../item-options'; | ||
|
|
||
| describe('ion-item-options: rtl', () => { | ||
| const newItemOptions = async (html: string, documentDir?: 'rtl') => { | ||
| const page = await newSpecPage({ components: [ItemOptions], html: `<div></div>` }); | ||
| if (documentDir) { | ||
| page.doc.documentElement.setAttribute('dir', documentDir); | ||
| } | ||
| await page.setContent(html); | ||
| return page.body.querySelector('ion-item-options')!; | ||
| }; | ||
|
|
||
| it('should change sides when it declares rtl', async () => { | ||
| const itemOptions = await newItemOptions(`<ion-item-options side="start" dir="rtl"></ion-item-options>`); | ||
| expect(itemOptions).toHaveClass('item-options-end'); | ||
| expect(itemOptions).not.toHaveClass('item-options-start'); | ||
| }); | ||
|
|
||
| it('should change sides when an ancestor declares rtl', async () => { | ||
| const itemOptions = await newItemOptions( | ||
| `<div dir="rtl"><div><ion-item-options side="start"></ion-item-options></div></div>` | ||
| ); | ||
| expect(itemOptions).toHaveClass('item-options-end'); | ||
| expect(itemOptions).not.toHaveClass('item-options-start'); | ||
| }); | ||
|
|
||
| it('should not change sides when an ancestor declares ltr in an rtl document', async () => { | ||
| const itemOptions = await newItemOptions( | ||
| `<div dir="ltr"><div><ion-item-options side="start"></ion-item-options></div></div>`, | ||
| 'rtl' | ||
| ); | ||
| expect(itemOptions).toHaveClass('item-options-start'); | ||
| expect(itemOptions).not.toHaveClass('item-options-end'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.