Skip to content

Commit

Permalink
Merge pull request #48 from emargareten/main
Browse files Browse the repository at this point in the history
Fix RTL Phone Number Display
  • Loading branch information
ysfkaya authored Aug 22, 2024
2 parents 8bb4529 + a9bfe51 commit b991c51
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
28 changes: 14 additions & 14 deletions src/Infolists/PhoneEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,33 @@ public function displayFormat(PhoneInputNumberType $format)

$format = $format->toLibPhoneNumberFormat();

if ($format === PhoneNumberFormat::RFC3966) {
$formatted = phone(
number: $state,
country: $country,
format: $format
);
$formatted = phone(
number: $state,
country: $country,
format: $format
);

if ($format === PhoneNumberFormat::RFC3966) {
$national = phone(
number: $state,
country: $country,
format: PhoneNumberFormat::NATIONAL
);

$html = <<<HTML
<a href="$formatted">
<a href="$formatted" dir="ltr">
$national
</a>
HTML;

return new HtmlString($html);
} else {
$html = <<<HTML
<span dir="ltr">
$formatted
</span>
HTML;
}

return phone(
number: $state,
country: $country,
format: $format
);
return new HtmlString($html);
} catch (NumberParseException $e) {
return $state;
}
Expand Down
29 changes: 16 additions & 13 deletions src/Tables/PhoneColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,36 @@ public function displayFormat(PhoneInputNumberType $format)

$format = $format->toLibPhoneNumberFormat();

if ($format === PhoneNumberFormat::RFC3966) {
$formatted = phone(
number: $state,
country: $country,
format: $format
);
$formatted = phone(
number: $state,
country: $country,
format: $format
);

if ($format === PhoneNumberFormat::RFC3966) {
$national = phone(
number: $state,
country: $country,
format: PhoneNumberFormat::NATIONAL
);

$html = <<<HTML
<a href="$formatted">
<a href="$formatted" dir="ltr">
$national
</a>
HTML;

return new HtmlString($html);

} else {
$html = <<<HTML
<span dir="ltr">
$formatted
</span>
HTML;
}

return phone(
number: $state,
country: $country,
format: $format
);

return new HtmlString($html);
} catch (NumberParseException $e) {
return $state;
}
Expand Down

0 comments on commit b991c51

Please sign in to comment.